[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.

-------------

Commit messages:
 - Allow PHASE_ERROR when disabling vthread events

Changes: https://git.openjdk.org/jdk/pull/11307/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=11307&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8297170
  Stats: 14 lines in 1 file changed: 11 ins; 0 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/11307.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/11307/head:pull/11307

PR: https://git.openjdk.org/jdk/pull/11307

Reply via email to