changeset 2329:0eb90baf1b69

6583275: Hotspot crash in vm_perform_shutdown_actions due to uninitialized TLS during out of memory handling Summary: Call get_thread_slow() in vm_perform_shutdown actions and add null check. Reviewed-by: kvn, dholmes, jcoomes
author coleenp
date Wed, 05 Jan 2011 21:23:15 -0500
parents 36c186bcc085
children 039eb4201e06
files src/share/vm/runtime/java.cpp
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/runtime/java.cpp	Mon Jan 03 14:09:11 2011 -0500
+++ b/src/share/vm/runtime/java.cpp	Wed Jan 05 21:23:15 2011 -0500
@@ -515,8 +515,8 @@
 }
 
 void vm_exit(int code) {
-  Thread* thread = ThreadLocalStorage::thread_index() == -1 ? NULL
-    : ThreadLocalStorage::get_thread_slow();
+  Thread* thread = ThreadLocalStorage::is_initialized() ?
+    ThreadLocalStorage::get_thread_slow() : NULL;
   if (thread == NULL) {
     // we have serious problems -- just exit
     vm_direct_exit(code);
@@ -553,8 +553,9 @@
   // Calling 'exit_globals()' will disable thread-local-storage and cause all
   // kinds of assertions to trigger in debug mode.
   if (is_init_completed()) {
-    Thread* thread = Thread::current();
-    if (thread->is_Java_thread()) {
+    Thread* thread = ThreadLocalStorage::is_initialized() ?
+                     ThreadLocalStorage::get_thread_slow() : NULL;
+    if (thread != NULL && thread->is_Java_thread()) {
       // We are leaving the VM, set state to native (in case any OS exit
       // handlers call back to the VM)
       JavaThread* jt = (JavaThread*)thread;