RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 695656 - possible race condition when using trap, signal is lost
Summary: possible race condition when using trap, signal is lost
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: bash
Version: 6.1
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: ---
Assignee: Roman Rakus
QA Contact: Martin Kyral
URL:
Whiteboard:
Depends On:
Blocks: 1025764
TreeView+ depends on / blocked
 
Reported: 2011-04-12 10:40 UTC by Jan Stancek
Modified: 2014-01-13 00:13 UTC (History)
4 users (show)

Fixed In Version: bash-4.1.2-12.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1025764 (view as bug list)
Environment:
Last Closed: 2013-02-21 08:07:24 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2013:0306 0 normal SHIPPED_LIVE bash bug fix and enhancement update 2013-02-20 20:35:32 UTC

Description Jan Stancek 2011-04-12 10:40:31 UTC
Description of problem:
This issue came up while running ltp cgroups regression tests.
Some of stress tests have very short loops and often call 'trap'. The task is then signalled, but the signal is occasionally 'lost'.

If this is known issue/limitation, which can't be fixed, perhaps a note could be added to man pages.

Version-Release number of selected component (if applicable):
Red Hat Enterprise Linux Server release 6.1 Beta (Santiago)
bash-4.1.2-8.el6.x86_64

How reproducible:
100% within 15 seconds

Steps to Reproduce:
1. run this script:
--- cut ---
#!/bin/bash

cat > traploop.sh <<EOF
while true; do
    trap exit SIGUSR1;
done
EOF

chmod a+x traploop.sh

i=0
while true; do
    ./traploop.sh &
    sleep 1
    echo "Sending SIGUSR1 to $!"
    kill -SIGUSR1 $!
    wait $!
    echo "No. $i: OK"
    i=$((i+1))
done
--- cut ---

Actual results:
Reproducer script gets stuck after couple of seconds.

Expected results:
Reproducer script will produce output each second.

Additional info:
Also reproducible on RHEL6.0, bash-4.1.2-3.el6.x86_64
Obvious workaround is to move trap outside the loop.

Comment 2 Roman Rakus 2011-04-12 12:08:52 UTC
Thanks for the report. Looks like the bug in re-setting signal handler. I will investigate it deeper.
For some reason bash set signal to be ignored before it set it to be handled and you hit the situation when it is ignored.

Comment 3 Roman Rakus 2011-04-13 02:53:21 UTC
Answer from upstream: http://www.mail-archive.com/bug-bash@gnu.org/msg09078.html

So it won't be changed. And I think it's not good set up trap many times if you can set it once at start. Is there any reason to set up trap in every loop run?

Comment 4 RHEL Program Management 2011-04-13 06:00:26 UTC
Since RHEL 6.1 External Beta has begun, and this bug remains
unresolved, it has been rejected as it is not proposed as
exception or blocker.

Red Hat invites you to ask your support representative to
propose this request, if appropriate and relevant, in the
next release of Red Hat Enterprise Linux.

Comment 5 Jan Stancek 2011-04-13 06:19:29 UTC
As for the cgroups tests in question
(./testcases/kernel/controllers/cgroup/test_*.sh), I don't see any reason to
keep it in loop. I'll CC author of the test.

Theoretically, you might want to change trap to use different handlers. Say you
want to handle signals coming at odd seconds with different handler than
signals coming at even seconds. One way would be to modify trap by switching
between 2 handlers.

> So it won't be changed. And I think it's not good set up trap many times
Sounds like a remark which could be added to man page.

Comment 6 Roman Rakus 2011-04-14 05:55:34 UTC
(In reply to comment #5)
> As for the cgroups tests in question
> (./testcases/kernel/controllers/cgroup/test_*.sh), I don't see any reason to
> keep it in loop. I'll CC author of the test.
> 
> Theoretically, you might want to change trap to use different handlers. Say you
> want to handle signals coming at odd seconds with different handler than
> signals coming at even seconds. One way would be to modify trap by switching
> between 2 handlers.
Or one handler which will check the seconds?
> 
> > So it won't be changed. And I think it's not good set up trap many times
> Sounds like a remark which could be added to man page.

Yes. It could be documented.

Comment 7 Roman Rakus 2011-04-18 12:42:21 UTC
The possible solution is to block the signal while the trap string and handler are
being modified.

Comment 8 RHEL Program Management 2011-07-05 23:41:14 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unfortunately unable to
address this request at this time. Red Hat invites you to
ask your support representative to propose this request, if
appropriate and relevant, in the next release of Red Hat
Enterprise Linux. If you would like it considered as an
exception in the current release, please ask your support
representative.

Comment 10 Suzanne Logcher 2012-02-14 23:08:26 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unfortunately unable to
address this request at this time. Red Hat invites you to
ask your support representative to propose this request, if
appropriate and relevant, in the next release of Red Hat
Enterprise Linux. If you would like it considered as an
exception in the current release, please ask your support
representative.

Comment 13 Roman Rakus 2012-08-28 11:00:13 UTC
Fixed in bash-4.1.2-12.el6

Comment 17 errata-xmlrpc 2013-02-21 08:07:24 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, and where to find the updated
files, follow the link below.

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

http://rhn.redhat.com/errata/RHBA-2013-0306.html


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