-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8320353: Reenable stringop-overflow warnings #26067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
8320353: Reenable stringop-overflow warnings #26067
Conversation
👋 Welcome back toxaart! A progress list of the required criteria for merging this PR into |
@toxaart This change is no longer ready for integration - check the PR body for details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build changes look good. Someone else will have to review the hotspot changes.
/reviewers 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but I really dislike seeing this compiler-specific pollution in shared code. It is even worse that you have to put it in two places (what is so special about the jvmci code to require this?) just because gcc is "too dumb" keep track of things.
Also IIUC from JBS the problem was only seen building Zero, so maybe we can do something there that is Zero specific?
Sorry.
#if defined(__GNUC__) && !defined(__clang__) && !defined(PRODUCT) | ||
if (thread == nullptr) { | ||
// This is to prevent --stringop-overflow warning from GCC on linux/fastdebug. | ||
// GCC does believe that JavaThread::current() can return nullptr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does believe
-> believes
@@ -1067,7 +1067,16 @@ class JavaThread: public Thread { | |||
public: | |||
// Returns the running thread as a JavaThread | |||
static JavaThread* current() { | |||
return JavaThread::cast(Thread::current()); | |||
auto result = JavaThread::cast(Thread::current()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why auto when the type is known?
A less messy solution could be to use PRAGMA_STRINGOP_OVERFLOW_IGNORED instead. The conditionals for the PRAGMA IGNORED macros are already all handled for you, so there's no need to put conditionalizations at the use sites. As an example, simply do the following: PRAGMA_DIAG_PUSH
PRAGMA_STRINGOP_OVERFLOW_IGNORED
// Problem code here
PRAGMA_DIAG_POP The first 2 macros are placed directly in front of the problem code, and the last goes behind. |
__builtin_unreachable(); | ||
} | ||
#endif | ||
return result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly here, I think this could be replaced with asserting non-null.
// therefore 2nd hint is needed. | ||
__builtin_unreachable(); | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be replaced with asserting non-null. A failed assert calls a noreturn reporting
function.
@@ -923,6 +923,17 @@ int CodeInstaller::estimate_stubs_size(HotSpotCompiledCodeStream* stream, JVMCI_ | |||
// perform data and call relocation on the CodeBuffer | |||
JVMCI::CodeInstallResult CodeInstaller::initialize_buffer(JVMCIObject compiled_code, CodeBuffer& buffer, HotSpotCompiledCodeStream* stream, u1 code_flags, JVMCI_TRAPS) { | |||
JavaThread* thread = stream->thread(); | |||
#if defined(__GNUC__) && !defined(__clang__) && !defined(PRODUCT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that !PRODUCT
does not imply ASSERT
. There is also the "optimized" build type, which
defines neither PRODUCT
nor ASSERT
. I have no idea whether the false-positive gcc warnings
occur in that build configuration. If so, then my suggestion of using an assertion to give the compiler
the clue it needs won't work. But I'm guessing that isn't a problem, in which case the macro check
should be defined(ASSERT)
.
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.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26067/head:pull/26067
$ git checkout pull/26067
Update a local copy of the PR:
$ git checkout pull/26067
$ git pull https://git.openjdk.org/jdk.git pull/26067/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26067
View PR using the GUI difftool:
$ git pr show -t 26067
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26067.diff
Using Webrev
Link to Webrev Comment