Summary: | Masked signals are delivered on thread exit | ||
---|---|---|---|
Product: | glibc | Reporter: | Gibeom Gwon <gb.gwon> |
Component: | nptl | Assignee: | Florian Weimer <fweimer> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | drepper.fsp, fryasu, fweimer |
Priority: | P2 | Flags: | fweimer:
security-
|
Version: | 2.33 | ||
Target Milestone: | 2.35 | ||
Host: | Target: | ||
Build: | Last reconfirmed: | 2021-11-18 00:00:00 | |
Attachments: | signal.c |
The signal mask initialization in start_thread happens in the wrong place. I have a fix. *** Bug 28612 has been marked as a duplicate of this bug. *** Fixed for glibc 2.35 via: commit e186fc5a31e46f2cbf5ea1a75223b4412907f3d8 Author: Florian Weimer <fweimer@redhat.com> Date: Wed Nov 24 08:59:54 2021 +0100 nptl: Do not set signal mask on second setjmp return [BZ #28607] __libc_signal_restore_set was in the wrong place: It also ran when setjmp returned the second time (after pthread_exit or pthread_cancel). This is observable with blocked pending signals during thread exit. Fixes commit b3cae39dcbfa2432b3f3aa28854d8ac57f0de1b8 ("nptl: Start new threads with all signals blocked [BZ #25098]"). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> |
Created attachment 13797 [details] signal.c I am experiencing strange behavior when using pthread with signals. If I set the signal mask with pthread_sigmask() in the thread function and the process has pending signal when thread is exiting, signal handler executed in thread. sleep.c ------- #include <unistd.h> int main() { sleep(50); return 0; } Compile sleep.c and signal.c. Run `signal` and hit Ctrl + C in the middle of running. Result is like this. $ ./signal main thread: 139882152073024 child thread: 139882152068672 worker... worker... worker... ^Csigint: 139882152073024 worker... worker... worker... worker... worker... worker... worker... thread close sigchld: 139882152068672