8217618: JVM TI SuspendThread doesn't suspend the current thread before returning

Reviewed-by: dcubed, sspitsyn, dlong
This commit is contained in:
David Holmes 2019-01-27 20:48:27 -05:00
parent 49c91b7f95
commit cb960e9a30
3 changed files with 37 additions and 23 deletions

View file

@ -2392,8 +2392,19 @@ void JavaThread::java_suspend() {
}
}
VM_ThreadSuspend vm_suspend;
VMThread::execute(&vm_suspend);
if (Thread::current() == this) {
// Safely self-suspend.
// If we don't do this explicitly it will implicitly happen
// before we transition back to Java, and on some other thread-state
// transition paths, but not as we exit a JVM TI SuspendThread call.
// As SuspendThread(current) must not return (until resumed) we must
// self-suspend here.
ThreadBlockInVM tbivm(this);
java_suspend_self();
} else {
VM_ThreadSuspend vm_suspend;
VMThread::execute(&vm_suspend);
}
}
// Part II of external suspension.