> 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).

Anton Artemov has updated the pull request incrementally with one additional 
commit since the last revision:

  8320353: Fixed build issue on aarch64 and riscv64-debug

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/31025/files
  - new: https://git.openjdk.org/jdk/pull/31025/files/d88d61da..2fdef125

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=31025&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=31025&range=00-01

  Stats: 2 lines in 2 files changed: 1 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/31025.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/31025/head:pull/31025

PR: https://git.openjdk.org/jdk/pull/31025

Reply via email to