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

Andreas Eriksson andreas.eriksson at oracle.com
Thu Feb 27 10:23:43 UTC 2014


Thanks Dmitry.

There are no crashes, only an assert that is hit if running with a debug 
build.
Otherwise the active threads keep growing, like you are seeing.

It is worrying that they keep growing with the patch as well.
I will have to look at it and see what can be done.

Regards,
Andreas

On 2014-02-26 21:14, Dmitry Samersoff wrote:
> Andreas,
>
> With JDK7 I didn't observe any crash with or without your patch.
> Without the patch the number of active threads constantly grows,
> with patch it remains the same.
>
>
> uname -a
> FreeBSD samersoff.net 9.2-RELEASE FreeBSD 9.2-RELEASE #1: Thu Jan  2
> 02:15:13 MSK 2014     dms at minext:/sys/amd64/compile/MIRCAT  amd64
>
>
> With patch:
>
> #java -version
>
> openjdk version "1.7.0_45"
> OpenJDK Runtime Environment (build 1.7.0_45-b18)
> OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
> Thread 80103f400 has exited with leftover thread-specific data after 4
> destructor iterations
>
> #$JAVA_HOME/bin/java -Djava.library.path=$NATIVE com.test.callback.App
>
> Java callback: native thread: 34376799232, java thread: Thread-391, 2
> active threads
> Successfully detached native thread 0x801045400
> Deleting callback
>
>
> Without patch:
>
> #/opt/openjdk7/bin/java -version
>
> openjdk version "1.7.0_25"
> OpenJDK Runtime Environment (build 1.7.0_25-b15)
> OpenJDK 64-Bit Server VM (build 23.21-b01, mixed mode)
>
> #/opt/openjdk7/bin/java -Djava.library.path=$NATIVE com.test.callback.App
>
> Java callback: native thread: 34376788992, java thread: Thread-402, 404
> active threads
> Successfully detached native thread 0x801042c00
> Deleting callback
>
> -Dmitry
>
>
> On 2014-02-10 20:21, Andreas Eriksson wrote:
>> Hi,
>>
>> Could I please get reviews for this change.
>> JBS: https://bugs.openjdk.java.net/browse/JDK-8033696
>> Webrev: http://cr.openjdk.java.net/~aeriksso/8033696/webrev.00/
>> Mail discussion:
>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2014-February/010759.html
>>
>>
>> Summary:
>> JNI code is using pthread_key_create with a destructor to detach the
>> thread from the JVM when the thread is exiting.
>> For some flavors of Linux and BSD 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.
>> This fix uses a destructor for the thread pointer that restores the
>> value, so that the JNI destructor can run detachCurrentThread successfully.
>> More info in JBS.
>>
>> Testing:
>> Native code regtest attached to JBS tested on Linux, but not on Mac
>> since I don't have access to one.
>> JPRT ran without a problem.
>>
>> Regards,
>> Andreas
>



More information about the hotspot-runtime-dev mailing list