RFR: 8339331: GCC fortify error in vm_version_linux_aarch64.cpp [v2]
Kim Barrett
kbarrett at openjdk.org
Tue Dec 17 05:13:37 UTC 2024
On Tue, 10 Dec 2024 10:18:13 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 one additional commit since the last revision:
>
> Use guarantee instead of assert to suppress gcc warnings
We've never been able to reproduce this at Oracle. We're using vanilla builds
of gcc. It might be that Fedora is applying a patch that leads to this. In
JDK-8316234 it was suggested there might be a gcc bug involved:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87489
Having read through that bug, I'm inclined to agree that's probably involved.
Much as I hate warning suppresions, I think a better solution here is to use
PRAGMA_NONNULL_IGNORED, along with a comment referring to that gcc bug, and
also mentioning that it might require some distro-specific gcc patch, since
not seen with vanilla gcc release.
-------------
Changes requested by kbarrett (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/22655#pullrequestreview-2507862983
More information about the hotspot-runtime-dev
mailing list