On Wed, 23 Nov 2022 02:22:46 GMT, Chris Plummer <cjplum...@openjdk.org> wrote:
> [JDK-8295376](https://bugs.openjdk.org/browse/JDK-8295376) introduced some > new code that disables JVMTI VIRTUAL_THREAD_START/END events when the > debugger disconnects. Sometimes this disabling attempt results in a > JVMTI_ERROR_WRONG_PHASE. The reason is because often the disconnect and > debuggee exit are happening at the same time. By the time the disable is > attempted, the VM has already sent (and the debug agent processed) the > VM_DEATH event, so the VM is now in JVMTI_PHASE_DEAD. > > To fix this I took the direct approach of just allowing > JVMTI_ERROR_WRONG_PHASE if VM_DEATH has been sent already. I could have tried > something more elegant that would have synchronized on the vmDeathLock, and > avoided the disabling call completely, but I didn't think the risk of a > deadlock was worth it, so I kept it simple. Marked as reviewed by amenkov (Reviewer). ------------- PR: https://git.openjdk.org/jdk/pull/11307