https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=246385
Bug ID: 246385 Summary: SIGCHLD dropped if generated while blocked in sigfastblock Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: b...@freebsd.org Reporter: corydo...@ridiculousfish.com Attachment #214394 text/plain mime type: Created attachment 214394 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=214394&action=edit reduced test case, see description for how to compile fish-shell is observing a hang under FreeBSD CURRENT which I believe to be a regression in FreeBSD signal handling, relative to 12.1. Originally reported as https://github.com/fish-shell/fish-shell/issues/6919 High level: if a process forks and the child exits before fork is complete in the parent, then SIGCHLD will not be delivered. Details: fork() will block signals using sigfastblock. If the child dies before signals are unblocked, the SIGCHLD will be marked as pending via the sigfastblock word. In this case fork() will issue a syscall to `sigfastblock(SIGFASTBLOCK_UNBLOCK)`; however SIGCHLD will NOT be delivered. Reduced test case attached as `demo.c`. This test case uses a loop which creates a child and waits for SIGCHLD to be delivered via the self-pipe trick. It counts every 256 iterations. To reproduce: clang demo.c ; ./a.out # this does not hang clang -lpthread demo.c ; ./a.out # this hangs on FreeBSD CURRENT only ktrace output: Good iteration (SIGCHLD generated while signals NOT blocked): 27181 a.out CALL fork 27181 a.out RET fork 27581/0x6bbd 27181 a.out CALL read(0x3,0x7fffffffe8e0,0x200) 27181 a.out RET read RESTART 27181 a.out PSIG SIGCHLD caught handler=0x800258dd0 mask=0x0 code=CLD_EXITED 27181 a.out CALL sigprocmask(SIG_SETMASK,0x7fffffffe24c,0) 27181 a.out RET sigprocmask 0 27181 a.out CALL write(0x4,0x7fffffffde6b,0x1) 27181 a.out GIO fd 4 wrote 1 byte 27181 a.out RET write 1 27181 a.out CALL sigreturn(0x7fffffffde80) 27181 a.out RET sigreturn JUSTRETURN 27181 a.out CALL read(0x3,0x7fffffffe8e0,0x200) 27181 a.out GIO fd 3 read 1 byte Hanging iteration (SIGCHLD generated while signals ARE blocked): 27181 a.out RET read 1 27181 a.out CALL wait4(0x6bbd,0x7fffffffe8d4,0x6<WUNTRACED|WCONTINUED>,0) 27181 a.out RET wait4 27581/0x6bbd 27181 a.out CALL fork 27181 a.out RET fork 27582/0x6bbe 27181 a.out CALL sigfastblock(0x2,0) 27181 a.out RET sigfastblock 0 27181 a.out CALL read(0x3,0x7fffffffe8e0,0x200) Note the call to sigfastblock(0x2) (pending signal) but PSIG SIGCHLD is not generated. -- You are receiving this mail because: You are the assignee for the bug. _______________________________________________ freebsd-bugs@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-bugs To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"