< prev index next >

src/hotspot/share/runtime/threadSMR.cpp

Print this page
rev 50688 : 8205195: NestedThreadsListHandleInErrorHandlingTest fails because hs_err doesn't contain _nested_thread_list_max
Summary: Grab Threads_lock in VMError::controlled_crash() so ErrorHandling tests are more stable.
Reviewed-by:

@@ -1065,12 +1065,19 @@
   }
 }
 
 // Print Threads class SMR info.
 void ThreadsSMRSupport::print_info_on(outputStream* st) {
-  // Only grab the Threads_lock if we don't already own it
-  // and if we are not reporting an error.
+  // Only grab the Threads_lock if we don't already own it and if we
+  // are not reporting an error.
+  // Note: Not grabbing the Threads_lock during during error reporting
+  // is dangerous because the data structures we want to print can be
+  // freed concurrently. However, grabbing the Threads_lock during
+  // error reporting can be equally dangerous since this thread might
+  // block during error reporting or a nested error could leave the
+  // Threads_lock held. The classic no win scenario.
+  //
   MutexLockerEx ml((Threads_lock->owned_by_self() || VMError::is_error_reported()) ? NULL : Threads_lock);
 
   st->print_cr("Threads class SMR info:");
   st->print_cr("_java_thread_list=" INTPTR_FORMAT ", length=%u, "
                "elements={", p2i(_java_thread_list),
< prev index next >