Skip to content

Commit

Permalink
8274136: -XX:+ExitOnOutOfMemoryError calls exit while threads are run…
Browse files Browse the repository at this point in the history
…ning

Reviewed-by: stuefe, hseigel
  • Loading branch information
David Holmes committed Sep 28, 2021
1 parent 53b25bc commit 2657bcb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/hotspot/os/posix/os_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,10 @@ void os::exit(int num) {
::exit(num);
}

void os::_exit(int num) {
::_exit(num);
}

// Builds a platform dependent Agent_OnLoad_<lib_name> function name
// which is used to find statically linked in agents.
// Parameters:
Expand Down
8 changes: 6 additions & 2 deletions src/hotspot/os/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4159,8 +4159,8 @@ int os::win32::exit_process_or_thread(Ept what, int exit_code) {
_endthreadex((unsigned)exit_code);
} else if (what == EPT_PROCESS) {
::exit(exit_code);
} else {
_exit(exit_code);
} else { // EPT_PROCESS_DIE
::_exit(exit_code);
}

// Should not reach here
Expand Down Expand Up @@ -4763,6 +4763,10 @@ void os::exit(int num) {
win32::exit_process_or_thread(win32::EPT_PROCESS, num);
}

void os::_exit(int num) {
win32::exit_process_or_thread(win32::EPT_PROCESS_DIE, num);
}

// Is a (classpath) directory empty?
bool os::dir_is_empty(const char* path) {
errno_t err;
Expand Down
6 changes: 5 additions & 1 deletion src/hotspot/share/runtime/os.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,13 @@ class os: AllStatic {
// child process (ignored on AIX, which always uses vfork).
static int fork_and_exec(const char *cmd, bool prefer_vfork = false);

// Call ::exit() on all platforms but Windows
// Call ::exit() on all platforms
static void exit(int num);

// Call ::_exit() on all platforms. Similar semantics to die() except we never
// want a core dump.
static void _exit(int num);

// Terminate the VM, but don't exit the process
static void shutdown();

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/utilities/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ void report_java_out_of_memory(const char* message) {

if (ExitOnOutOfMemoryError) {
tty->print_cr("Terminating due to java.lang.OutOfMemoryError: %s", message);
os::exit(3);
os::_exit(3); // quick exit with no cleanup hooks run
}
}
}
Expand Down

1 comment on commit 2657bcb

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.