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

JNI attached threads can be seen to be partially constructed

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      When a native thread attaches to the VM through JNI_AttachCurrentThread it needs a java.lang.Thread object to be constructed for it. However to construct a Thread object requires execution of Java code, and to execute Java code an attached thread must have a Thread object and appear as a fully fledged java.lang.Thread, and VM JavaThread and appear in the threads_list etc. This catch-22 is currently addressed by attaching the native thread to a raw unconstructed Thread object, setting some essential values whilst in native code, and then calling into the VM to execute the Thread constructor to complete the initialization of the Thread object. This means that while executing the constructor the associated Thread object contains default initialized values (ie zero or null) for things like its name and ID. Because the Thread is visible to the system (eg jvmti and mmx code) at this stage it is possible for these zero values to trigger exceptions or even (in the past) VM crashes.

      We need to find a way to fully create the Thread object without exposing it with unitinitalized values.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dsimms David Simms
              Reporter:
              dholmes David Holmes
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: