Skip to content

Commit ea5672d

Browse files
authored
Fix #3651: Prevent crash during shutdown in Frankenphp (#3662)
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
1 parent f4ce0bf commit ea5672d

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

ext/signals.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,20 @@ static int dd_call_prev_handler(bool flush) {
375375
}
376376

377377
static int dd_sigterm_cleanup_thread(void *arg) {
378+
// Block all signals to prevent delivery to this thread
379+
sigset_t set;
380+
sigfillset(&set);
381+
sigprocmask(SIG_BLOCK, &set, NULL);
382+
383+
// Make the Go runtime believe, we are actually running on a signal stack
384+
stack_t altstack;
385+
altstack.ss_sp = dd_signal_async_stack;
386+
if (altstack.ss_sp) {
387+
altstack.ss_size = dd_signal_async_stack_size;
388+
altstack.ss_flags = 0;
389+
sigaltstack(&altstack, NULL);
390+
}
391+
378392
return dd_call_prev_handler(true);
379393
}
380394

0 commit comments

Comments
 (0)