Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1577907

Summary: ksh memory leak in subshell.c when there are traps installed
Product: Red Hat Enterprise Linux 7 Reporter: Paulo Andrade <pandrade>
Component: kshAssignee: Siteshwar Vashisht <svashisht>
Status: CLOSED DUPLICATE QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.6CC: qe-baseos-apps, svashisht
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1577902 Environment:
Last Closed: 2018-09-10 14:57:31 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: 1577902    
Bug Blocks:    

Description Paulo Andrade 2018-05-14 12:18:03 UTC
+++ This bug was initially created as a clone of Bug #1577902 +++

Reproducer:

1. Run the script
---8<---8<---
#!/bin/ksh
  
function  funcTERM
{
    exit 0
}
  
trap  funcTERM  SIGTERM
  
while true
do
    i=0
    while [ $i -lt 100 ]
    do
        DUMMY=`echo dummy`
        let ++i
    done
    ps u --no-headers -p $$ 
    sleep 0.1
done
---8<---8<---

2. Keep looking at 6th column(RSS) of ps
# ./check.ksh 
root      8643  0.0  0.3 109344  1668 pts/1    S+   13:19   0:00 /bin/ksh ./check.ksh
...
root      8643  4.2  0.4 109600  2136 pts/1    S+   13:19   0:00 /bin/ksh ./check.ksh
root      8643  4.3  0.4 109600  2148 pts/1    R+   13:19   0:00 /bin/ksh ./check.ksh
root      8643  4.3  0.4 109600  2148 pts/1    S+   13:19   0:00 /bin/ksh ./check.ksh

Minimal patch to correct the problem:
"""
diff -up ksh-20120801/src/cmd/ksh93/sh/subshell.c.orig ksh-20120801/src/cmd/ksh93/sh/subshell.c
--- ksh-20120801/src/cmd/ksh93/sh/subshell.c.orig	2018-05-11 13:45:12.280999698 -0300
+++ ksh-20120801/src/cmd/ksh93/sh/subshell.c	2018-05-11 13:46:19.396000044 -0300
@@ -575,7 +575,7 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_
 		sp->coutpipe = shp->coutpipe;
 		sp->cpipe = shp->cpipe[1];
 		shp->cpid = 0;
-		sh_sigreset(0);
+		sh_sigreset(1);
 	}
 	jmpval = sigsetjmp(buff.buff,0);
 	if(jmpval==0)
"""

  The patch could be made a bit longer, but more complex, to avoid the strdup
calls that will be just released shortly after (with this patch).

** Note ** the equivalent patch is required in xec.c, but there is no reproducer
so far for the leak, that would happen in the same conditions (sh_sigreset zero'ing
the vector of strdup'ed strings).

Comment 1 Siteshwar Vashisht 2018-09-10 14:57:31 UTC

*** This bug has been marked as a duplicate of bug 1460940 ***