Mercurial > hg > graal-jvmci-8
comparison src/os/linux/vm/os_linux.cpp @ 17845:21dd1c827123
8033696: "assert(thread != NULL) failed: just checking" due to Thread::current() and JNI pthread interaction
Reviewed-by: dholmes, dsamersoff
Contributed-by: andreas.eriksson@oracle.com
author | kevinw |
---|---|
date | Wed, 02 Apr 2014 18:40:52 +0200 |
parents | 56e7f5560e60 |
children | 6048424d3865 |
comparison
equal
deleted
inserted
replaced
17843:81d7a4b28dc5 | 17845:21dd1c827123 |
---|---|
1072 } | 1072 } |
1073 | 1073 |
1074 ////////////////////////////////////////////////////////////////////////////// | 1074 ////////////////////////////////////////////////////////////////////////////// |
1075 // thread local storage | 1075 // thread local storage |
1076 | 1076 |
1077 // Restore the thread pointer if the destructor is called. This is in case | |
1078 // someone from JNI code sets up a destructor with pthread_key_create to run | |
1079 // detachCurrentThread on thread death. Unless we restore the thread pointer we | |
1080 // will hang or crash. When detachCurrentThread is called the key will be set | |
1081 // to null and we will not be called again. If detachCurrentThread is never | |
1082 // called we could loop forever depending on the pthread implementation. | |
1083 static void restore_thread_pointer(void* p) { | |
1084 Thread* thread = (Thread*) p; | |
1085 os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread); | |
1086 } | |
1087 | |
1077 int os::allocate_thread_local_storage() { | 1088 int os::allocate_thread_local_storage() { |
1078 pthread_key_t key; | 1089 pthread_key_t key; |
1079 int rslt = pthread_key_create(&key, NULL); | 1090 int rslt = pthread_key_create(&key, restore_thread_pointer); |
1080 assert(rslt == 0, "cannot allocate thread local storage"); | 1091 assert(rslt == 0, "cannot allocate thread local storage"); |
1081 return (int)key; | 1092 return (int)key; |
1082 } | 1093 } |
1083 | 1094 |
1084 // Note: This is currently not used by VM, as we don't destroy TLS key | 1095 // Note: This is currently not used by VM, as we don't destroy TLS key |