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
8262092: vmTestbase/nsk/jvmti/scenarios/hotswap/HS102/hs102t001/TestDescription.java SIGSEGV in memmove_ssse3 #3889
Conversation
|
@alexmenkov 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.
Also, generic comment. There are other counters which might require synchronization, like CompiledMethodLoadEventsCount. Doesn't it makes sense to fix them also or file a new bug?
@@ -67,6 +67,8 @@ static char** names = NULL; | |||
static jvmtiClassDefinition* old_class_def = NULL; | |||
static jvmtiClassDefinition* new_class_def = NULL; | |||
static int classCount = 0; | |||
/* lock to access classCount */ | |||
static jrawMonitorID classLoadLock = NULL; |
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 it would simpler to use an atomic counter rather than monitors for this fix.
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.
Do you mean use atomic from STL?
I'm not sure it would be simpler as we need logic like "get the value, if the value is less than max_classes, increment it"
if (!NSK_JVMTI_VERIFY(jvmti_env->Allocate(class_data_len, (unsigned char**) | ||
&old_class_def[classCount].class_bytes))) { | ||
// use while instead of if to exit the block on error | ||
while (classCount < max_classes) { |
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.
Could you please explain why this while is executed only once. It is not obvious.
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 tried to explain it in the comment :)
it should be "if (classCount < max_classes)",
but inside the if we have return statements and we need to do cleanup (exit monitor).
So I used well-known pattern with 1-pass cycle (note that "return"s are replaced with "break"s)
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.
Offline discussion shown that I forgot to add break at the end of the cycle. Will fix
The problem with classCount is it's used as an index in the arrays. |
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.
This looks good.
Thanks,
Serguei
@alexmenkov This change now passes all automated pre-integration checks. 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 23 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.
|
/integrate |
@alexmenkov Since your change was applied there have been 65 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 9713152. |
Class loading can happen on different threads, but HotSwap agent is not ready to this - classCount variable is used without any synchronization.
The fix adds synchronization for ClassFileLoadHook.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3889/head:pull/3889
$ git checkout pull/3889
Update a local copy of the PR:
$ git checkout pull/3889
$ git pull https://git.openjdk.java.net/jdk pull/3889/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 3889
View PR using the GUI difftool:
$ git pr show -t 3889
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3889.diff