|Issue||Fix Version||Assignee||Priority||Status||Resolution||Resolved In Build|
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.