On Tue, 1 Jul 2025 12:25:04 GMT, Anton Artemov <d...@openjdk.org> wrote:
> Hi, please consider the following changes: > > this PR addresses the issue of stringop-overflow warnings produced by GCC. > The compiler does think that the thread pointer returned by > `JavaThread::current()` can be null, though it cant. The thread pointer ends > up being an argument in `__atomic_load`, and the compiler reports the warning > related to argument of that method. > > The patch adds a hint to the compiler by means of `__builtin_unreachable()` > intrinsic, which tells the compiler that certain piece of code will never be > reached (case of thread pointer being null). This solves the issue. > > Tested in tiers 1-3 and GHA. My suggestion of using assertions instead doesn't seem to work, still getting bogus warnings. This is with gcc14.2 on linux-aarch64, which also uses __atomic_load. That is mysteriously weird. The noreturn reporting function should be roughly equivalent to calling an ordinary function with an "unreachable" following it. But then, this whole issue is mysteriously weird. But that's okay; I wasn't really all that keen on adding assertions to suppress bogus compiler warnings anyway. At this point I think this change should just not be made. It's a compiler bug. The existing suppression of the warnings is fine with me. I think what's really needed is for someone to file a gcc bug. It's too bad nobody did that when the issue was first noticed. There's already a bug that is similar, and might even be the same, even though it involves sanitizers and ours doesn't: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113775 ------------- PR Comment: https://git.openjdk.org/jdk/pull/26067#issuecomment-3030839463