Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/hotspot/share/jvmci/jvmci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ char* JVMCI::_shared_library_path = nullptr;
volatile bool JVMCI::_in_shutdown = false;
StringEventLog* JVMCI::_events = nullptr;
StringEventLog* JVMCI::_verbose_events = nullptr;
volatile intx JVMCI::_fatal_log_init_thread = -1;
volatile intx JVMCI::_first_error_tid = -1;
volatile int JVMCI::_fatal_log_fd = -1;
const char* JVMCI::_fatal_log_filename = nullptr;

Expand Down Expand Up @@ -354,7 +354,7 @@ void JVMCI::fatal_log(const char* buf, size_t count) {
intx current_thread_id = os::current_thread_id();
intx invalid_id = -1;
int log_fd;
if (_fatal_log_init_thread == invalid_id && Atomic::cmpxchg(&_fatal_log_init_thread, invalid_id, current_thread_id) == invalid_id) {
if (_first_error_tid == invalid_id && Atomic::cmpxchg(&_first_error_tid, invalid_id, current_thread_id) == invalid_id) {
if (ErrorFileToStdout) {
log_fd = 1;
} else if (ErrorFileToStderr) {
Expand All @@ -375,14 +375,13 @@ void JVMCI::fatal_log(const char* buf, size_t count) {
}
}
_fatal_log_fd = log_fd;
} else {
// Another thread won the race to initialize the stream. Give it time
// to complete initialization. VM locks cannot be used as the current
// thread might not be attached to the VM (e.g. a native thread started
// within libjvmci).
while (_fatal_log_fd == -1) {
os::naked_short_sleep(50);
}
} else if (_first_error_tid != current_thread_id) {
// This is not the first thread reporting a libjvmci error
tty->print_cr("[thread " INTX_FORMAT " also had an error in the JVMCI native library]",
current_thread_id);

// Fatal error reporting is single threaded so just block this thread.
os::infinite_sleep();
}
fdStream log(_fatal_log_fd);
log.write(buf, count);
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/jvmci/jvmci.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ class JVMCI : public AllStatic {
// The path of the file underlying _fatal_log_fd if it is a normal file.
static const char* _fatal_log_filename;

// Native thread id of thread that will initialize _fatal_log_fd.
static volatile intx _fatal_log_init_thread;
// Thread id of the first thread reporting a libjvmci error.
static volatile intx _first_error_tid;

// JVMCI event log (shows up in hs_err crash logs).
static StringEventLog* _events;
Expand Down