Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8173693

disable post_class_unload() for non JavaThread initiators

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 8, 9, 10
    • hotspot
    • None
    • b157
    • generic
    • generic

        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)) {

              dcubed Daniel Daugherty
              dcubed Daniel Daugherty
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: