JDK-8173693 : disable post_class_unload() for non JavaThread initiators
  • Type: Bug
  • Component: hotspot
  • Sub-Component: jvmti
  • Affected Version: 8,9,10
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2017-01-31
  • Updated: 2017-02-23
  • Resolved: 2017-01-31
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 9
10Fixed 9 b157Fixed
Related Reports
Relates :  
Description
The current post_class_unload() function can crash the
VM when a non JavaThread initiates a class unload event.
It is also possible that the non JavaThread can be
corrupted instead of crashing the VM.

Until JDK-8173658 can be fixed for non JavaThread
initiators of a class unload event, the function should
disabled.

$ hg diff src/share/vm//prims/jvmtiExport.cpp
diff -r 28e800db5a8e src/share/vm/prims/jvmtiExport.cpp
--- a/src/share/vm/prims/jvmtiExport.cpp        Sat Jan 28 14:10:02 2017 -0700
+++ b/src/share/vm/prims/jvmtiExport.cpp        Mon Jan 30 16:31:27 2017 -0700
@@ -1285,8 +1285,12 @@
     assert(thread->is_VM_thread(), "wrong thread");
 
     // get JavaThread for whom we are proxy
-    JavaThread *real_thread =
-        (JavaThread *)((VMThread *)thread)->vm_operation()->calling_thread();
+    Thread *calling_thread = ((VMThread *)thread)->vm_operation()->calling_thread();
+    if (!calling_thread->is_Java_thread()) {
+      // cannot post an event to a non-JavaThread
+      return;
+    }
+    JavaThread *real_thread = (JavaThread *)calling_thread;
 
     JvmtiEnvIterator it;
     for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
Comments
Converted from a sub-task of JDK-8173658 to an issue (Bug) because it wasn't showing up on the dashboards that we use to track stuff for the JDK9 end game.
31-01-2017