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 1176670 - Problem with alarm and IFS
Summary: Problem with alarm and IFS
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: ksh
Version: 6.4
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Michal Hlavinka
QA Contact: Martin Kyral
URL:
Whiteboard:
Depends On:
Blocks: 1360483 1406448
TreeView+ depends on / blocked
 
Reported: 2014-12-22 18:59 UTC by Paulo Andrade
Modified: 2020-12-11 11:45 UTC (History)
7 users (show)

Fixed In Version: ksh-20120801-25.el6
Doc Type: Bug Fix
Doc Text:
Previously, ksh terminated unexpectedly after an alarm occurred during a read operation with a modified Internal Field Separator (IFS). The ksh alarm built-in has been modified to preserve the IFS table during execution. As a result, ksh no longer crashes in this situation.
Clone Of:
: 1192118 1192119 1360483 (view as bug list)
Environment:
Last Closed: 2015-07-22 06:56:27 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
ksh-20120801-alarm.patch (996 bytes, patch)
2014-12-22 19:00 UTC, Paulo Andrade
no flags Details | Diff
ksh-20120801-ifstable.patch (453 bytes, patch)
2014-12-22 19:02 UTC, Paulo Andrade
no flags Details | Diff
ksh-20120801-ifstable.patch (897 bytes, patch)
2014-12-22 19:04 UTC, Paulo Andrade
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:1450 0 normal SHIPPED_LIVE ksh bug fix update 2015-07-20 18:43:49 UTC

Description Paulo Andrade 2014-12-22 18:59:21 UTC
This problem is specific to all releases, and fedora, up
to rawhide.

A simple test case is:
---%<---
#!/bin/ksh
toto="s"
alarm -r alarm_handler +1
function alarm_handler.alarm
{
if [[ $toto == "s" ]]
then
toto="e"
else
toto="f"
fi
}
IFS=","
(echo "2";sleep 1;echo "3") | while IFS="," read  arg1
#(echo "2";sleep 1;echo "3") | while  read  arg1
do
print "$arg1"
done
---%<---

There is a small thread about it at
http://lists.research.att.com/pipermail/ast-users/2014q4/004684.html

I had made an initial one liner patch that address
specifically the problem, but I was not happy with
it because it probably would just hide other issues
that may arise from alarms.

Anyway, I will only propose a simple patch for
cases where there are no exceptions involved.

This was an off list reply I received:
---%<---
[...]
Subject: Re: [ast-users] [PATCH] Problem with alarm and IFS
From: David Korn <dgkorn>
To: =?UTF-8?Q?Paulo_C=C3=A9sar_Pereira_de_Andrade?= <paulo.cesar.pereira.de.andrade>
Content-Type: multipart/alternative; boundary=001a113ab2ba6fd291050a9c0dcd

--001a113ab2ba6fd291050a9c0dcd
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

I never documented the alarm builtin because it is problematic.  The
problem is that traps can't safely be handled asynchronously.  What should
happen is that the trap is marked for execution (sh_trapnote) and run after
the current command completes.  The time trap should wake up the shell if
it is blocked and it should return and then handle the trap.

That being said, I will pick up both of our patches since they don't do
harm and improve the undocumented alarm builtin.
[...]
---%<---

Comment 1 Paulo Andrade 2014-12-22 19:00:48 UTC
Created attachment 972117 [details]
ksh-20120801-alarm.patch

This is the patch I propose to be applied on
rhel and fedora ksh packages.

Comment 2 Paulo Andrade 2014-12-22 19:02:09 UTC
Created attachment 972118 [details]
ksh-20120801-ifstable.patch

Minimal one liner patch that correct the problem.
This patch should be in upstream ksh now.

Comment 3 Paulo Andrade 2014-12-22 19:04:03 UTC
Created attachment 972126 [details]
ksh-20120801-ifstable.patch

Alternate simple patch, that should also be in upstream
now. This is a slightly simpler version of
ksh-20120801-alarm.patch

Comment 5 Michal Hlavinka 2015-02-12 17:13:53 UTC
I don't understand it clearly from the comments. What patches were included upstream? Both 2 and 3?

Comment 6 Paulo Andrade 2015-02-12 17:45:38 UTC
Sorry for somewhat confusing patches attached.
The two patches named ksh-20120801-ifstable.patch
should be in upstream, either corrects the
problem (one overwrites the test condition that
would cause an infinite loop, the other save
and restore the ifstable during the alarm).

There is no newer tarball at
http://www2.research.att.com/sw/download/
so I cannot confirm to be 100% sure it has been
added. The email from David Korn I did cut&paste
is talking about the two patches named
ksh-20120801-ifstable.patch that were posted
to ast-users mailing list.

The patch named  ksh-20120801-alarm.patch 
is an attempt to save&restore more state in an alarm,
but is likely incomplete, that is, there may be
other states that should be save/restored for
possible other issues, like exceptions, during the
alarm, but no known test case.

Comment 11 errata-xmlrpc 2015-07-22 06:56:27 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.

https://rhn.redhat.com/errata/RHBA-2015-1450.html


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