Skip to content

Commit 2657bcb

Browse files
author
David Holmes
committed
8274136: -XX:+ExitOnOutOfMemoryError calls exit while threads are running
Reviewed-by: stuefe, hseigel
1 parent 53b25bc commit 2657bcb

4 files changed

Lines changed: 16 additions & 4 deletions

File tree

src/hotspot/os/posix/os_posix.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,10 @@ void os::exit(int num) {
732732
::exit(num);
733733
}
734734

735+
void os::_exit(int num) {
736+
::_exit(num);
737+
}
738+
735739
// Builds a platform dependent Agent_OnLoad_<lib_name> function name
736740
// which is used to find statically linked in agents.
737741
// Parameters:

src/hotspot/os/windows/os_windows.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4159,8 +4159,8 @@ int os::win32::exit_process_or_thread(Ept what, int exit_code) {
41594159
_endthreadex((unsigned)exit_code);
41604160
} else if (what == EPT_PROCESS) {
41614161
::exit(exit_code);
4162-
} else {
4163-
_exit(exit_code);
4162+
} else { // EPT_PROCESS_DIE
4163+
::_exit(exit_code);
41644164
}
41654165

41664166
// Should not reach here
@@ -4763,6 +4763,10 @@ void os::exit(int num) {
47634763
win32::exit_process_or_thread(win32::EPT_PROCESS, num);
47644764
}
47654765

4766+
void os::_exit(int num) {
4767+
win32::exit_process_or_thread(win32::EPT_PROCESS_DIE, num);
4768+
}
4769+
47664770
// Is a (classpath) directory empty?
47674771
bool os::dir_is_empty(const char* path) {
47684772
errno_t err;

src/hotspot/share/runtime/os.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,13 @@ class os: AllStatic {
520520
// child process (ignored on AIX, which always uses vfork).
521521
static int fork_and_exec(const char *cmd, bool prefer_vfork = false);
522522

523-
// Call ::exit() on all platforms but Windows
523+
// Call ::exit() on all platforms
524524
static void exit(int num);
525525

526+
// Call ::_exit() on all platforms. Similar semantics to die() except we never
527+
// want a core dump.
528+
static void _exit(int num);
529+
526530
// Terminate the VM, but don't exit the process
527531
static void shutdown();
528532

src/hotspot/share/utilities/debug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ void report_java_out_of_memory(const char* message) {
366366

367367
if (ExitOnOutOfMemoryError) {
368368
tty->print_cr("Terminating due to java.lang.OutOfMemoryError: %s", message);
369-
os::exit(3);
369+
os::_exit(3); // quick exit with no cleanup hooks run
370370
}
371371
}
372372
}

0 commit comments

Comments
 (0)