changeset 13352:ebab242c2824

8184339: Thread::current_or_null() shall not assert if Posix TLS is not yet initialized Reviewed-by: dcubed, coleenp
author stuefe
date Thu, 13 Jul 2017 16:28:14 +0200
parents 7b38202df6fd
children a414aa7bc5ba
files src/share/vm/runtime/thread.hpp
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/runtime/thread.hpp	Tue Jul 18 15:43:07 2017 +0200
+++ b/src/share/vm/runtime/thread.hpp	Thu Jul 13 16:28:14 2017 +0200
@@ -674,12 +674,18 @@
 #ifndef USE_LIBRARY_BASED_TLS_ONLY
   return _thr_current;
 #else
-  return ThreadLocalStorage::thread();
+  if (ThreadLocalStorage::is_initialized()) {
+    return ThreadLocalStorage::thread();
+  }
+  return NULL;
 #endif
 }
 
 inline Thread* Thread::current_or_null_safe() {
-  return ThreadLocalStorage::thread();
+  if (ThreadLocalStorage::is_initialized()) {
+    return ThreadLocalStorage::thread();
+  }
+  return NULL;
 }
 
 // Name support for threads.  non-JavaThread subclasses with multiple