From owner-freebsd-bugs@freebsd.org Mon May 11 19:56:54 2020 Return-Path: Delivered-To: freebsd-bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CB4232E9CD6 for ; Mon, 11 May 2020 19:56:54 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 49LWsy54QYz41NX for ; Mon, 11 May 2020 19:56:54 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id AC5962E9CD5; Mon, 11 May 2020 19:56:54 +0000 (UTC) Delivered-To: bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AC1F32E9CD4 for ; Mon, 11 May 2020 19:56:54 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49LWsy44b9z41NW for ; Mon, 11 May 2020 19:56:54 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 876AE23B90 for ; Mon, 11 May 2020 19:56:54 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 04BJusCs068745 for ; Mon, 11 May 2020 19:56:54 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 04BJusW3068744 for bugs@FreeBSD.org; Mon, 11 May 2020 19:56:54 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 246385] SIGCHLD dropped if generated while blocked in sigfastblock Date: Mon, 11 May 2020 19:56:54 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: corydoras@ridiculousfish.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.mimetype attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 May 2020 19:56:54 -0000 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= ,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.=