Date: Mon, 11 May 2020 19:56:54 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 246385] SIGCHLD dropped if generated while blocked in sigfastblock Message-ID: <bug-246385-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D246385 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: bugs@FreeBSD.org Reporter: corydoras@ridiculousfish.com Attachment #214394 text/plain mime type: Created attachment 214394 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D214394&action= =3Dedit 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 be= fore 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 tri= ck. 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=3D0x800258dd0 mask=3D0x0 code=3DCLD_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. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-246385-227>