-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8290732: JNI DestroyJavaVM can start shutdown when one non-daemon thread remains #9803
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
Conversation
|
👋 Welcome back dholmes! A progress list of the required criteria for merging this PR into |
|
@dholmes-ora The following labels 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 lists. 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.
Hi David,
that was interesting. I always thought you have to detach before destroying the VM.
I looked into https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/invocation.html and it says:
"Detaching from the VM: A native thread attached to the VM must call DetachCurrentThread() to detach itself before exiting."
Cheers, Thomas
| * @build Main | ||
| * @run main/native TestDaemonDestroy | ||
| * @run main/native TestDaemonDestroy daemon | ||
| */ |
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.
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 didn't think that was warranted/necessary here.
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 disagree. Splitting the test leads causes better runtime (on my 24 core machine: 10.5 seconds vs 16 seconds). It also makes the jtr file easier to read, since it only contains one test. It also is simpler to run a selected test if you want to reproduce an error.
It is regrettable that splitting the test section causes too much duplication. Maybe we could improve the jtreg syntax in the future.
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.
But you also have to duplicate the build instructions and building takes longer than execution on my systems (7 seconds versus 5) so if I had to pay for machine time I'd actually be worse off now!
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.
Oh, you are right. That's unfortunate.
|
Thanks for fixing this. I'm glad my reproducer gave you a good start, but you had to do all the grunt work of error checking and jtreg conversion. :-) Things look reasonable to me, but I'm not too familiar with this code and with Hotspot testing, so I'll defer to other reviewers. |
tstuefe
left a comment
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.
|
@dholmes-ora 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 63 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 |
tstuefe
left a comment
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.
Still good.
|
Thanks @tstuefe ! Can I get second review please. |
robehn
left a comment
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!
|
Thanks @robehn ! /integrate |
|
Going to push as commit 6eb7c3a.
Your commit was automatically rebased without conflicts. |
|
@dholmes-ora Pushed as commit 6eb7c3a. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Please review this fix for a problem discovered by @stuart-marks in the course of examining the VM shutdown behaviour. The VM code assumed that only unattached threads called JNI's DestroyJavaVM and so they were always attached as non-daemon threads. But it is perfectly valid to call DestroyJavaVM from an already attached thread, which could be a daemon. The fix simply checks whether the caller is a daemon or not and adjusts the expected count of active threads to see. There is also an adjustment to the thread termination logic to also notify at the right time.
Thanks to @stuart-marks for the reproducer in JBS - the longest part of this by many hours was converting the test over the jtreg. :)
Testing:
Thanks.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9803/head:pull/9803$ git checkout pull/9803Update a local copy of the PR:
$ git checkout pull/9803$ git pull https://git.openjdk.org/jdk pull/9803/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 9803View PR using the GUI difftool:
$ git pr show -t 9803Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9803.diff