On Tue, 5 May 2026 02:04:33 GMT, Fei Yang <[email protected]> wrote: >> Hi, please consider the following changes: >> >> This PR re-enables stringop-overflow warnings. >> >> It was assumed that the assert in `Thread::current()`, which calls the >> `ATTRIBUTE_NORETURN` report function on failure, would be sufficient to >> inform the GCC compiler that the current thread is always non-null. However, >> it turns out that the assert is weakened by the `DebuggingContext`: >> >> Instead of having >> `assert(current != nullptr, "Thread::current() called on detached thread");` >> >> in fact one gets this: >> `if ( !(DebuggingContext::is_enabled() || current != null) ) { >> report_vm_error(...); }` >> >> If `DebuggingContext` is enabled then the error will not be triggered >> regardless of what `current` is. This makes GCC consider the virtually >> impossible path and emit false positive warnings about atomics. >> >> The same problem is found in the Shenandoah code. >> >> The fix is to strengthen the assertion by >> `DEBUG_ONLY(guarantee(current != nullptr, "...");)` >> which removes the assertion completely in product builds, but for debug >> builds makes it clear for the compiler that the operand cannot be nullptr. >> >> With this findings I conclude that it is not a compiler bug. >> >> Tested in tiers 1-5 and GHA. >> >> Separate builds with Shenandoah done. >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Hi, just FYI. I just tried building a native fastdebug build with this change > on linux-riscv64 using GCC 14. Unfortunately, I found that the previous issue > https://bugs.openjdk.org/browse/JDK-8382522 is still triggering. And the > build warnings are the same as before: > https://bugs.openjdk.org/secure/attachment/119512/build.log
@RealFYang, @shqking thanks for trying to build it, I identified the 2 problematic places and fixed them. ------------- PR Comment: https://git.openjdk.org/jdk/pull/31025#issuecomment-4378628609
