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

"assert(thread != NULL) failed: just checking" due to Thread::current() and JNI pthread interaction

    XMLWordPrintable

Details

    • b10
    • x86_64
    • generic

    Backports

      Description


        JNI code is using pthread_key_create with a destructor to detach the thread from the JVM when the thread is exiting.

        This solution works well when running on Solaris or a 32 bit JVM on Linux, but when run on 64 bit JVM on Linux the threads hang when detaching.

        For 64 bit Linux the JVM is also using the pthread_key_create, to store the

        Thread::current() value in a thread local storage.

        Since the thread local storage containing the thread pointer is erased (by pthread) before the JNI destructor runs, we run detachCurrentThread on a thread that has NULL as current thread.

        With a product build this breaks locks/monitors, and the threads hang. With a debug build an assert in Thread::current() is hit instead.

        Everything works if detachCurrentThread is called from the main logic instead.

        Attachments

          1. callback_jni.tar.gz
            3 kB
          2. runMac.sh
            0.6 kB
          3. thread_pointer.patch
            0.7 kB

          Issue Links

            Activity

              People

                aeriksso Andreas Eriksson (Inactive)
                asaha Abhijit Saha
                Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: