Skip to content

Commit cb403c9

Browse files
Revert "reset signal handlers to their system defaults if handling crash with UseOSErrorReporting"
This reverts commit f634064.
1 parent f634064 commit cb403c9

File tree

6 files changed

+9
-39
lines changed

6 files changed

+9
-39
lines changed

src/hotspot/os/posix/signals_posix.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,17 +1414,6 @@ void PosixSignals::hotspot_sigmask(Thread* thread) {
14141414
}
14151415
}
14161416

1417-
void PosixSignals::clear_signal_handlers() {
1418-
// set signal handlers back to their defaults
1419-
struct sigaction defaulthandler;
1420-
sigemptyset(&defaulthandler.sa_mask);
1421-
1422-
defaulthandler.sa_handler = SIG_DFL;
1423-
for (int i = 0; i < NSIG + 1; i++) {
1424-
sigaction(i, &defaulthandler, NULL);
1425-
}
1426-
}
1427-
14281417
////////////////////////////////////////////////////////////////////////////////
14291418
// suspend/resume support
14301419

src/hotspot/os/posix/signals_posix.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ class PosixSignals : public AllStatic {
4848
static int unblock_thread_signal_mask(const sigset_t *set);
4949
static void hotspot_sigmask(Thread* thread);
5050

51-
// set signal handlers back to their system defaults (i.e. no handler)
52-
// to let the process die at the crash site (so that the OS can
53-
// catch and process it)
54-
static void clear_signal_handlers();
55-
5651
static void print_signal_handler(outputStream* st, int sig, char* buf, size_t buflen);
5752

5853
static address ucontext_get_pc(const ucontext_t* ctx);

src/hotspot/os/posix/vmError_posix.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static void crash_handler(int sig, siginfo_t* info, void* ucVoid) {
138138
VMError::report_and_die(NULL, sig, pc, info, ucVoid);
139139
}
140140

141-
void VMError::rearm_signal_handlers() {
141+
void VMError::reset_signal_handlers() {
142142
// install signal handlers for all synchronous program error signals
143143
sigset_t newset;
144144
sigemptyset(&newset);
@@ -151,10 +151,6 @@ void VMError::rearm_signal_handlers() {
151151
PosixSignals::unblock_thread_signal_mask(&newset);
152152
}
153153

154-
void VMError::clear_signal_handlers() {
155-
PosixSignals::clear_signal_handlers();
156-
}
157-
158154
// Write a hint to the stream in case siginfo relates to a segv/bus error
159155
// and the offending address points into CDS archive.
160156
void VMError::check_failing_cds_access(outputStream* st, const void* siginfo) {

src/hotspot/os/windows/vmError_windows.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,10 @@ LONG WINAPI crash_handler(struct _EXCEPTION_POINTERS* exceptionInfo) {
4444
return EXCEPTION_CONTINUE_SEARCH;
4545
}
4646

47-
void VMError::rearm_signal_handlers() {
47+
void VMError::reset_signal_handlers() {
4848
SetUnhandledExceptionFilter(crash_handler);
4949
}
5050

51-
void VMError::clear_signal_handlers() {
52-
}
53-
5451
// Write a hint to the stream in case siginfo relates to a segv/bus error
5552
// and the offending address points into CDS archive.
5653
void VMError::check_failing_cds_access(outputStream* st, const void* siginfo) {

src/hotspot/share/utilities/vmError.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,19 +1429,14 @@ void VMError::report_and_die(int id, const char* message, const char* detail_fmt
14291429

14301430
os::check_dump_limit(buffer, sizeof(buffer));
14311431

1432-
// Rearm signal handlers (Linux, macOS) or exception filter (Windows)
1433-
// to make sure that recursive crashes are handled properly.
1434-
rearm_signal_handlers();
1432+
// reset signal handlers or exception filter; make sure recursive crashes
1433+
// are handled properly.
1434+
reset_signal_handlers();
14351435
} else {
14361436
// If UseOsErrorReporting we call this for each level of the call stack
14371437
// while searching for the exception handler. Only the first level needs
14381438
// to be reported.
1439-
if (UseOSErrorReporting && log_done) {
1440-
// We already handled the signal once, so reset signal handlers
1441-
// to their defaults and let OS handle it after the process will die
1442-
clear_signal_handlers();
1443-
return;
1444-
}
1439+
if (UseOSErrorReporting && log_done) return;
14451440

14461441
// This is not the first error, see if it happened in a different thread
14471442
// or in the same thread during error reporting.

src/hotspot/share/utilities/vmError.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,9 @@ class VMError : public AllStatic {
8888

8989
public:
9090

91-
// reset signal handlers to the default exception filter
92-
// to handle recursive crashes
93-
static void rearm_signal_handlers();
94-
95-
static void clear_signal_handlers();
91+
// set signal handlers on Solaris/Linux or the default exception filter
92+
// on Windows, to handle recursive crashes.
93+
static void reset_signal_handlers();
9694

9795
// handle -XX:+ShowMessageBoxOnError. buf is used to format the message string
9896
static void show_message_box(char* buf, int buflen);

0 commit comments

Comments
 (0)