@@ -50,7 +50,7 @@ char* JVMCI::_shared_library_path = nullptr;
5050volatile bool JVMCI::_in_shutdown = false ;
5151StringEventLog* JVMCI::_events = nullptr ;
5252StringEventLog* JVMCI::_verbose_events = nullptr ;
53- volatile intx JVMCI::_fatal_log_init_thread = -1 ;
53+ volatile intx JVMCI::_first_error_tid = -1 ;
5454volatile int JVMCI::_fatal_log_fd = -1 ;
5555const char * JVMCI::_fatal_log_filename = nullptr ;
5656
@@ -354,7 +354,7 @@ void JVMCI::fatal_log(const char* buf, size_t count) {
354354 intx current_thread_id = os::current_thread_id ();
355355 intx invalid_id = -1 ;
356356 int log_fd;
357- if (_fatal_log_init_thread == invalid_id && Atomic::cmpxchg (&_fatal_log_init_thread , invalid_id, current_thread_id) == invalid_id) {
357+ if (_first_error_tid == invalid_id && Atomic::cmpxchg (&_first_error_tid , invalid_id, current_thread_id) == invalid_id) {
358358 if (ErrorFileToStdout) {
359359 log_fd = 1 ;
360360 } else if (ErrorFileToStderr) {
@@ -375,14 +375,13 @@ void JVMCI::fatal_log(const char* buf, size_t count) {
375375 }
376376 }
377377 _fatal_log_fd = log_fd;
378- } else {
379- // Another thread won the race to initialize the stream. Give it time
380- // to complete initialization. VM locks cannot be used as the current
381- // thread might not be attached to the VM (e.g. a native thread started
382- // within libjvmci).
383- while (_fatal_log_fd == -1 ) {
384- os::naked_short_sleep (50 );
385- }
378+ } else if (_first_error_tid != current_thread_id) {
379+ // This is not the first thread reporting a libjvmci error
380+ tty->print_cr (" [thread " INTX_FORMAT " also had an error in the JVMCI native library]" ,
381+ current_thread_id);
382+
383+ // Fatal error reporting is single threaded so just block this thread.
384+ os::infinite_sleep ();
386385 }
387386 fdStream log (_fatal_log_fd);
388387 log.write (buf, count);
0 commit comments