Bug 2176707

Summary: glibc: system() erroneously block SIGCHLD forever when called concurrently
Product: Red Hat Enterprise Linux 8 Reporter: Adam Yi <ayi>
Component: glibcAssignee: DJ Delorie <dj>
Status: CLOSED ERRATA QA Contact: Martin Coufal <mcoufal>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.7CC: ashankar, codonell, cperl, dj, fweimer, mcermak, pfrankli, phr, sipoyare
Target Milestone: rcKeywords: Bugfix, Patch, Triaged
Target Release: 8.9   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: glibc-2.28-233.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of:
: 2177235 (view as bug list) Environment:
Last Closed: 2023-11-14 15:49:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2177235    
Bug Blocks:    
Attachments:
Description Flags
Reproduction none

Description Adam Yi 2023-03-09 02:59:27 UTC
Created attachment 1949201 [details]
Reproduction

We backported a buggy commit (5fb7fc96350575c9adb1316833e48ca11553be49) in bug 2065588 that landed in glibc-2.28-211.

Specifically, in the following scenario with two threads in the same process:

1. Thread A calls system but hasn't returned yet
2. Thread B calls another system but returns

I observed that SIGCHLD would be blocked forever in thread B after its system() returns, even after the system() in thread A returns (though I believe it should unblock it after system() in thread B returns). This was not the case before this patch.

I've attached a simple C reproduction program to this bug. It doesn't print anything on previously but prints "SIGCHLD is erroneously blocked" with glibc-2.28-211.

I filed this bug upstream (sourceware bug 30163) and this is fixed in upstream in 436a604b7dc741fc76b5a6704c6cd8bb178518e7. Can we backport the fix as well?

Comment 1 Florian Weimer 2023-03-10 14:19:27 UTC
Thank you for filing this bug for tracking purposes. We are considering fixing it in a future minor release of Red Hat Enterprise Linux 8. If you have specific timeline requirements for the fix, please file a customer support ticket in Customer Portal at: https://access.redhat.com/support/cases/

Comment 2 Florian Weimer 2023-04-28 11:19:29 UTC
Upstream fix:

commit 436a604b7dc741fc76b5a6704c6cd8bb178518e7
Author: Adam Yi <ayi>
Date:   Tue Mar 7 07:30:02 2023 -0500

    posix: Fix system blocks SIGCHLD erroneously [BZ #30163]
    
    Fix bug that SIGCHLD is erroneously blocked forever in the following
    scenario:
    
    1. Thread A calls system but hasn't returned yet
    2. Thread B calls another system but returns
    
    SIGCHLD would be blocked forever in thread B after its system() returns,
    even after the system() in thread A returns.
    
    Although POSIX does not require, glibc system implementation aims to be
    thread and cancellation safe. This bug was introduced in
    5fb7fc96350575c9adb1316833e48ca11553be49 when we moved reverting signal
    mask to happen when the last concurrently running system returns,
    despite that signal mask is per thread. This commit reverts this logic
    and adds a test.
    
    Signed-off-by: Adam Yi <ayi>
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella>

Comment 8 errata-xmlrpc 2023-11-14 15:49:05 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (glibc bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:7107