Bug 2177235 - glibc: system() erroneously block SIGCHLD forever when called concurrently
Summary: glibc: system() erroneously block SIGCHLD forever when called concurrently
Keywords:
Status: VERIFIED
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: glibc
Version: 9.2
Hardware: Unspecified
OS: Linux
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Florian Weimer
QA Contact: Sergey Kolosov
Jacob Taylor Valdez
URL:
Whiteboard:
Depends On:
Blocks: 2176707 2188641
TreeView+ depends on / blocked
 
Reported: 2023-03-10 14:17 UTC by Arjun Shankar
Modified: 2023-08-01 10:11 UTC (History)
13 users (show)

Fixed In Version: glibc-2.34-67.el9
Doc Type: Bug Fix
Doc Text:
.The `glibc` `system()` function now restores the previous signal mask unconditionally Previously, if the `glibc` `system()` function was called concurrently from multiple threads, the signal mask for the `SIGCHLD` signal might not be restored correctly. As a consequence, the `SIGCHLD` signal remained blocked after the return from the `glibc` `system()` function on some threads. With this update, the `glibc` `system()` function now restores the previous signal mask unconditionally, even when parallel `system()` function calls are running. As a result, the `SIGCHLD` signal is no longer incorrectly blocked if the `glibc` `system()` function is called concurrently from multiple threads.
Clone Of: 2176707
Environment:
Last Closed:
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-151441 0 None None None 2023-03-10 14:18:49 UTC
Sourceware 30163 0 P2 RESOLVED system() erroneously block SIGCHLD forever when called concurrently 2023-03-10 14:39:04 UTC

Description Arjun Shankar 2023-03-10 14:17:32 UTC
+++ This bug was initially created as a clone of Bug #2176707 +++

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 2 Florian Weimer 2023-04-28 11:19:48 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 Jacob Taylor Valdez 2023-08-01 10:11:56 UTC
setting r_d_t


Note You need to log in before you can comment on or make changes to this bug.