Commit dee3186e authored by Philip Pronin's avatar Philip Pronin Committed by facebook-github-bot-0

setup signal handler with SA_ONSTACK

Summary:
By default signal handlers are run on the signaled thread's stack.
In case of stack overflow running the `SIGSEGV` signal handler on
the same stack leads to another `SIGSEGV` and crashes the program
Use `SA_ONSTACK`, so alternate stack is used (only if configured via
`sigaltstack`).

Reviewed By: luciang

Differential Revision: D2747021

fb-gh-sync-id: 48388acd6147e2919412ec32acfca1ca76f22a16
parent d8ebd43d
......@@ -322,7 +322,12 @@ void installFatalSignalHandler() {
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sigemptyset(&sa.sa_mask);
sa.sa_flags |= SA_SIGINFO;
// By default signal handlers are run on the signaled thread's stack.
// In case of stack overflow running the SIGSEGV signal handler on
// the same stack leads to another SIGSEGV and crashes the program.
// Use SA_ONSTACK, so alternate stack is used (only if configured via
// sigaltstack).
sa.sa_flags |= SA_SIGINFO | SA_ONSTACK;
sa.sa_sigaction = &signalHandler;
for (auto p = kFatalSignals; p->name; ++p) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment