src/hotspot/share/runtime/thread.cpp
changeset 53518 2181425e0460
parent 53305 d193d58ae79d
child 53582 881c5fbeb849
--- a/src/hotspot/share/runtime/thread.cpp	Mon Jan 28 08:01:06 2019 +0900
+++ b/src/hotspot/share/runtime/thread.cpp	Sun Jan 27 20:48:27 2019 -0500
@@ -2392,8 +2392,19 @@
     }
   }
 
-  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.