-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
8295375: debug agent class tracking should not piggy back on the cbClassPrepare() callback #10776
Conversation
@@ -1265,7 +1265,6 @@ enableEvents(HandlerNode *node) | |||
case EI_THREAD_END: | |||
case EI_VM_INIT: | |||
case EI_VM_DEATH: | |||
case EI_CLASS_PREPARE: |
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.
Since CLASS_PREPARE is no longer globally and permanently enabled, we remove it from this list so the code below can enable it as needed based on whether or not the debugger as requested CLASS_PREPARE events.
/* We must keep track of all classes prepared to know what's unloaded */ | ||
if (evinfo->ei == EI_CLASS_PREPARE) { | ||
classTrack_addPreparedClass(env, evinfo->clazz); | ||
} | ||
|
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.
We no longer need this hack here since the class tracking code now installs its own CLASS_PREPARE event handler.
error = threadControl_setEventMode(JVMTI_ENABLE, | ||
EI_CLASS_PREPARE, NULL); | ||
if (error != JVMTI_ERROR_NONE) { | ||
EXIT_ERROR(error,"Can't enable class prepare events"); | ||
} |
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.
We no longer permanently enable CLASS_PREPARE events here. It's now done in classTrack.c, and only impacts the JVMTIEnv that is used for class tracking.
👋 Welcome back cjplummer! A progress list of the required criteria for merging this PR into |
@plummercj 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. |
@plummercj 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 21 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 |
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.
Good simplification.
Thanks,
Serguei
Thank you Alex and Serguei! /integrate |
Going to push as commit 2181042.
Your commit was automatically rebased without conflicts. |
@plummercj Pushed as commit 2181042. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
The debug agent needs to keep track of all loaded classes, and also be notified when they are unloaded. It tracks classes loading by getting CLASS_PREPARE events and it tracks their unloading by tagging them, which triggers OBJECT_FREE events when they are unloaded. The tagging and OBJECT_FREE events are handled by a separate JVMTIEnv from the one that does main event handling, mostly in support of the attached debugger. However, the CLASS_PREPARE events are piggy backed on the main event handler. As a result, we have this special check in filterAndHandleEvent():
We also have to always keep CLASS_PREPARE events enabled on the main event handler, even if the debugger is not requesting them. The main event handler has a lot of overhead that isn't necessary when simply wanting to use the CLASS_PREPARE event for class tracking.
Another downside of this piggy backing is it causes problems for addressing JDK-8295376, which is attempting to not track virtual threads when the debugger is not attached (no VIRTUAL_THREAD_START and VIRTUAL_THREAD_END events). The problem is when the debugger is not attached and a CLASS_PREPARE event comes in on a virtual thread, the debug agent unnecessarily creates a ThreadNode for it. Since there won't be a corresponding VIRTUAL_THREAD_END event when the virtual thread is destroyed (as long as the debugger is not attached), the debug agent ends up keeping this ThreadNode around even after the thread is gone. This usually eventually leads to an assert.
The fix for this is pretty simple. We already have the separate JVMTIEnv that the class tracker uses to handle OBJECT_FREE. This is easily purposed to also handle CLASS_PREPARE events. By doing so we can get rid of the special CLASS_PREPARE code above in filterAndHandleEvent(), and we also only need to enable CLASS_PREPARE events for the main event handler when a debugger is attached and is requesting them.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10776/head:pull/10776
$ git checkout pull/10776
Update a local copy of the PR:
$ git checkout pull/10776
$ git pull https://git.openjdk.org/jdk pull/10776/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 10776
View PR using the GUI difftool:
$ git pr show -t 10776
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10776.diff