-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Description
Version
Platform
Linux 5.19.11-amd64 #1 SMP x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
LD_PRELOAD or link in any library that sets a signal handler and schedules signal delivery (e.g. a posix timer).
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior?
The library handles own signals.
What do you see instead?
The program crashes.
Additional information
#615 added this code that resets all signal handlers to SIG_DFL:
Lines 426 to 434 in 0c46051
// The hard-coded upper limit is because NSIG is not very reliable; on Linux, | |
// it evaluates to 32, 34 or 64, depending on whether RT signals are enabled. | |
// Counting up to SIGRTMIN doesn't work for the same reason. | |
for (unsigned nr = 1; nr < kMaxSignal; nr += 1) { | |
if (nr == SIGKILL || nr == SIGSTOP) | |
continue; | |
act.sa_handler = (nr == SIGPIPE || nr == SIGXFSZ) ? SIG_IGN : SIG_DFL; | |
CHECK_EQ(0, sigaction(nr, &act, nullptr)); | |
} |
This causes crashes is there is a signal handler installed.
While SIG_IGN can indeed be inherited across execve, all actual handlers (not SIG_IGN/DFL) are reset to SIG_DFL.
So I think the startup code should reset to SIG_DFL iff the handler is set of SIG_IGN. Any real handlers should be left intact.
Metadata
Metadata
Assignees
Labels
No labels