RFR: 8339331: GCC fortify error in vm_version_linux_aarch64.cpp [v3]
Kim Barrett
kbarrett at openjdk.org
Tue Dec 17 17:44:39 UTC 2024
On Tue, 17 Dec 2024 10:01:20 GMT, SendaoYan <syan at openjdk.org> wrote:
>> Hi all,
>> The file src/hotspot/os_cpu/linux_aarch64/vm_version_linux_aarch64.cpp report nullptr compile warning by gcc14 with fastdebug configure. I think it's false positive, since the statement 'assert(buf != nullptr, "invalid argument");' has make sure the buf should not be nullptr before execute '::read(int, void*, int)'. The call chain is `void VM_Version::initialize_cpu_information(void)` -> `void VM_Version::get_compatible_board(char *buf, int buflen)` -> `static bool read_fully(const char *fname, char *buf, size_t buflen)`, `*buf` is defined as `char Abstract_VM_Version::_cpu_desc[4096] = {0};` and then right shift 8 bytes, so `*buf` should not be nullptr.
>> This PR use guarantee instead of assert to suppress false positive gcc compile warning to make fastdebug configure make success on linux-aarch64 by gcc14.2.0.
>> Risk is low.
>>
>> Additional testing:
>>
>> - [x] jtreg tests(include tier1/2/3) on linux-x64 with release build
>> - [x] jtreg tests(include tier1/2/3) on linux-x64 with fastdebug build
>> - [x] jtreg tests(include tier1/2/3) on linux-aarch64 with release build
>> - [x] jtreg tests(include tier1/2/3) on linux-aarch64 with fastdebug build
>
> SendaoYan has updated the pull request incrementally with two additional commits since the last revision:
>
> - revert to "invalid argument"
> - Use PRAGMA_NONNULL_IGNORED to suppress gcc compile warning, and add comments about the gcc bug
Changes requested by kbarrett (Reviewer).
src/hotspot/os_cpu/linux_aarch64/vm_version_linux_aarch64.cpp line 192:
> 190: // Use pragma to suppress false positive gcc compile warning which maybe be gcc bug
> 191: // recorded by https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87489. The false positive warning
> 192: // not seen with vanilla gcc release since maybe include some distro-specific gcc patch.
The wording of the comment is a bit awkward and ungrammatical. Suggest something like:
Suppress false positive gcc warning, which may be an example of
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87489
The warning also hasn't been seen with vanilla gcc release, so may also
involve some distro-specific gcc patch.
-------------
PR Review: https://git.openjdk.org/jdk/pull/22655#pullrequestreview-2509626617
PR Review Comment: https://git.openjdk.org/jdk/pull/22655#discussion_r1888955578
More information about the hotspot-runtime-dev
mailing list