RFR: 8319818: Address GCC 13.2.0 warnings (stringop-overflow and dangling-pointer)
Hao Sun
haosun at openjdk.org
Fri Nov 10 01:47:56 UTC 2023
On Thu, 9 Nov 2023 16:07:53 GMT, Mikael Vidstedt <mikael at openjdk.org> wrote:
> This PR is splitting out the GCC 13.2.0 warning related changes from #16550, excluding the Oracle/devkit parts, for clarity and to make potential backports more straightforward.
>
> GCC 13.2.0 generates two new warnings:
>
> * linux-aarch64-debug
>
> src/hotspot/os_cpu/linux_aarch64/atomic_linux_aarch64.hpp:203:66: error: 'long unsigned int __atomic_load_8(const volatile void*, int)' writing 8 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=]
>
> I did not find any way to adjust the code to avoid this warning, so I instead chose to disable it in `CompileJvm.gmk` for linux-aarch64-(fast)debug only.
>
> * linux-zero
>
> src/hotspot/share/runtime/thread.hpp:579:77: error: storing the address of local variable 'rm' in '*_thr_current.Thread::_current_resource_mark' [-Werror=dangling-pointer=]
>
> Lots and lots of warnings related to ResourceMark. Thanks to @stefank for suggesting moving the ASSERT implementation of the ResourceMark constructor to the .cpp file. With that change there's no need to explicitly disable the warning.
As for `dangling-pointer`, to be honest, I didn't fully understand why such a change could work. But it's nice to see that we can avoid compiler warnings by proper code modifications.
As for `stringop-overflow`, we encountered this warning before.
1) https://bugs.openjdk.org/browse/JDK-8294031, gcc-12 raised the same warnings for the same file, i.e. `atomic_linux_aarch64.hpp`. After several fixes by @kimbarrett, this warning is gone.
2) https://bugs.openjdk.org/browse/JDK-8299580, gcc-12 also raised the same warnings for risc-v in the similar way, for file `atomic_linux_riscv.hpp`. And as suggested by @kimbarrett, this might be one fundamental problem and we can hold on before we fully understand it.
Hi @kimbarrett, can we have your comments for this warning? Thanks.
make/hotspot/lib/CompileJvm.gmk line 93:
> 91: ifeq ($(DEBUG_LEVEL), fastdebug)
> 92: ifeq ($(call And, $(call isTargetOs, linux) $(call isTargetCpu, aarch64)), true)
> 93: DISABLED_WARNINGS_gcc += stringop-overflow
Do you think it would be better if we add some comments here?
Suggestion:
# False positive warnings for atomic_linux_aarch64.hpp on GCC >= 13
DISABLED_WARNINGS_gcc += stringop-overflow
-------------
PR Review: https://git.openjdk.org/jdk/pull/16584#pullrequestreview-1723782910
PR Review Comment: https://git.openjdk.org/jdk/pull/16584#discussion_r1388766021
More information about the build-dev
mailing list