diff -r 365e137617ff -r 5698cf4e50f1 src/hotspot/share/utilities/vmError.cpp --- a/src/hotspot/share/utilities/vmError.cpp Fri Jun 22 18:49:45 2018 +0300 +++ b/src/hotspot/share/utilities/vmError.cpp Fri Jun 22 12:15:16 2018 -0400 @@ -1698,6 +1698,13 @@ // Case 15 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java. // Case 16 is tested by test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java. // Case 17 is tested by test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java. + + // We grab Threads_lock to keep ThreadsSMRSupport::print_info_on() + // from racing with Threads::add() or Threads::remove() as we + // generate the hs_err_pid file. This makes our ErrorHandling tests + // more stable. + MutexLockerEx ml(Threads_lock, Mutex::_no_safepoint_check_flag); + switch (how) { case 1: vmassert(str == NULL, "expected null"); break; case 2: vmassert(num == 1023 && *str == 'X',