-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
8275049: [ZGC] missing null check in ZNMethod::log_register #5892
8275049: [ZGC] missing null check in ZNMethod::log_register #5892
Conversation
👋 Welcome back mdoerr! A progress list of the required criteria for merging this PR into |
@TheRealMDoerr The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
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.
The oops we read here are written in c1_Runtime, while holding the Patching_lock. However, the Patching_lock is not held when registering. In other words, someone could be writing an oop while we are reading it in this loop, due to C1 patching. If the loads re-order in here, we may crash the VM. Since we have plain loads, the compiler is free to re-order. I think the solution I would go with, is to use the CompiledICLocker instead where we patch the code in C1. That ends up taking the per-nmethod lock, that we can hold while logging this. That makes sure that accessing the oops implies mutual exclusion. Then we can remove the Patching_lock, since it is only ever used in that one place.
Hi Erik, |
I think we could just Atomic::load(p) for now to deal with the null check, and then see if we want to deal with the other race condition another day. |
src/hotspot/share/gc/z/zNMethod.cpp
Outdated
@@ -126,8 +126,10 @@ void ZNMethod::log_register(const nmethod* nm) { | |||
oop* const begin = nm->oops_begin(); | |||
oop* const end = nm->oops_end(); | |||
for (oop* p = begin; p < end; p++) { | |||
const char* external_name = (*p) == nullptr ? "null" | |||
: (*p)->klass()->external_name(); |
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.
Apart from doing an Atomic::load() here, I'd also suggest we write "N/A" instead of "null", since the class isn't really null.
Thanks for your suggestions. They make sense. |
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.
Looks good.
@TheRealMDoerr This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 27 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
src/hotspot/share/gc/z/zNMethod.cpp
Outdated
log_oops.print(" Oop[" SIZE_FORMAT "] " PTR_FORMAT " (%s)", | ||
(p - begin), p2i(*p), (*p)->klass()->external_name()); | ||
(p - begin), p2i(*p), external_name); |
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.
p2i(*p)
should be p2i(o)
now
src/hotspot/share/gc/z/zNMethod.cpp
Outdated
@@ -126,8 +126,11 @@ void ZNMethod::log_register(const nmethod* nm) { | |||
oop* const begin = nm->oops_begin(); | |||
oop* const end = nm->oops_end(); | |||
for (oop* p = begin; p < end; p++) { | |||
oop o = Atomic::load(p); // C1 PatchingStub may replace it concurrently. | |||
const char* external_name = o == nullptr ? "N/A" | |||
: o->klass()->external_name(); |
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.
Can we please make this a single line, and add parenthesis around (o == nullptr)
src/hotspot/share/gc/z/zNMethod.cpp
Outdated
@@ -126,8 +126,11 @@ void ZNMethod::log_register(const nmethod* nm) { | |||
oop* const begin = nm->oops_begin(); | |||
oop* const end = nm->oops_end(); | |||
for (oop* p = begin; p < end; p++) { | |||
oop o = Atomic::load(p); // C1 PatchingStub may replace it concurrently. |
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.
Can we please make this const oop o = ...
Good catch. Thanks! |
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.
Thanks for fixing. Looks good!
Thanks for the reviews! |
Going to push as commit cf82867.
Your commit was automatically rebased without conflicts. |
@TheRealMDoerr Pushed as commit cf82867. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
The VM crashes while trying to read (*p)->klass() in "ZNMethod::log_register" on PPC64. We need a null check. See JBS for details.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5892/head:pull/5892
$ git checkout pull/5892
Update a local copy of the PR:
$ git checkout pull/5892
$ git pull https://git.openjdk.java.net/jdk pull/5892/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 5892
View PR using the GUI difftool:
$ git pr show -t 5892
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5892.diff