Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 586923

Summary: ksh memory leak significantly slows the execution of shell scripts
Product: Red Hat Enterprise Linux 5 Reporter: Tomas Smetana <tsmetana>
Component: kshAssignee: Michal Hlavinka <mhlavink>
Status: CLOSED ERRATA QA Contact: qe-baseos-tools-bugs
Severity: urgent Docs Contact:
Priority: urgent    
Version: 5.5CC: bz-reply, cww, gbarros, jwest, kvolny, mfranc, mpoole, msvoboda, ovasik, plyons, tao
Target Milestone: rcKeywords: Patch, ZStream
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Due to a memory leak in the ksh executable, the performance of long running scripts could decrease significantly over the time. With this update, the underlying source code has been modified to prevent this memory leak, and the execution of long running scripts is no longer slowed down.
Story Points: ---
Clone Of:
: 588710 (view as bug list) Environment:
Last Closed: 2012-02-21 05:49:38 UTC Type: ---
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:    
Bug Blocks: 502912, 590060, 674552    
Attachments:
Description Flags
Reproducer script
none
Proposed patch
none
A better patch none

Description Tomas Smetana 2010-04-28 14:13:46 UTC
Run the attached script and observe the results. Here's the sample of the output of the different ksh93 versions:

The previous version of the Korn Shell:
==================================================================================
# ./loop_time_gets_longer  

ksh version: Version M 93s+ 2008-01-31

  +-------------- pass number
  |            +- current loop time/1st loop time
  |            |  process size --------------------------------------+
  |            |  total time in seconds ----------------+            |
  |            |  current loop time +                   |            |
  |            |                    |                   |            |
 \ /          \ /                  \ /                 \ /          \ /
p#   1: cur/1st= 1.00; loop(secs)=  1.56; total(secs)=    1.56; RSS=0001592
p#   2: cur/1st= 0.99; loop(secs)=  1.55; total(secs)=    3.11; RSS=0001604
p#   3: cur/1st= 1.00; loop(secs)=  1.56; total(secs)=    4.67; RSS=0001604
p#   4: cur/1st= 1.00; loop(secs)=  1.56; total(secs)=    6.23; RSS=0001604
p#   5: cur/1st= 1.00; loop(secs)=  1.56; total(secs)=    7.79; RSS=0001604
p#   6: cur/1st= 1.00; loop(secs)=  1.57; total(secs)=    9.36; RSS=0001604
p#   7: cur/1st= 1.00; loop(secs)=  1.56; total(secs)=   10.92; RSS=0001604
p#   8: cur/1st= 1.01; loop(secs)=  1.57; total(secs)=   12.49; RSS=0001604
p#   9: cur/1st= 1.00; loop(secs)=  1.56; total(secs)=   14.06; RSS=0001604
p#  10: cur/1st= 1.00; loop(secs)=  1.56; total(secs)=   15.62; RSS=0001604

================================================================================

The new Korn Shell:
================================================================================
# ./loop_time_gets_longer  

ksh version: Version AJM 93t+ 2010-02-02

  +-------------- pass number
  |            +- current loop time/1st loop time
  |            |  process size --------------------------------------+
  |            |  total time in seconds ----------------+            |
  |            |  current loop time +                   |            |
  |            |                    |                   |            |
 \ /          \ /                  \ /                 \ /          \ /
p#   1: cur/1st= 1.00; loop(secs)=  5.43; total(secs)=    5.43; RSS=0069952
p#   2: cur/1st= 2.31; loop(secs)= 12.56; total(secs)=   17.99; RSS=0138524
p#   3: cur/1st= 3.46; loop(secs)= 18.78; total(secs)=   36.77; RSS=0207088
p#   4: cur/1st= 4.52; loop(secs)= 24.53; total(secs)=   61.31; RSS=0275656
p#   5: cur/1st= 5.51; loop(secs)= 29.93; total(secs)=   91.24; RSS=0344220
p#   6: cur/1st= 6.46; loop(secs)= 35.09; total(secs)=  126.33; RSS=0412784
p#   7: cur/1st= 7.39; loop(secs)= 40.15; total(secs)=  166.48; RSS=0481344
p#   8: cur/1st= 8.33; loop(secs)= 45.23; total(secs)=  211.70; RSS=0549912
p#   9: cur/1st= 9.29; loop(secs)= 50.48; total(secs)=  262.18; RSS=0618480
p#  10: cur/1st=10.22; loop(secs)= 55.49; total(secs)=  317.67; RSS=0687040

Version-Release number of selected component (if applicable):
ksh-20100202-1.el5

How reproducible:
always

Steps to Reproduce:
See the description

Comment 1 Tomas Smetana 2010-04-28 14:15:08 UTC
Created attachment 409846 [details]
Reproducer script

Comment 2 Tomas Smetana 2010-04-28 14:16:00 UTC
Created attachment 409847 [details]
Proposed patch

Backported from 2010-03-09 upstream version.

Comment 3 Tomas Smetana 2010-05-18 07:32:40 UTC
Created attachment 414760 [details]
A better patch

There seems to be another leak caused by a forgotten initialization

Comment 5 RHEL Program Management 2010-08-09 18:20:24 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.

Comment 10 RHEL Program Management 2011-01-11 20:21:58 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.

Comment 12 RHEL Program Management 2011-01-11 22:44:05 UTC
This request was erroneously denied for the current release of
Red Hat Enterprise Linux.  The error has been fixed and this
request has been re-proposed for the current release.

Comment 22 Miroslav Svoboda 2012-01-18 08:55:50 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Due to a memory leak in the ksh executable, the performance of long running scripts could decrease significantly over the time. With this update, the underlying source code has been modified to prevent this memory leak, and the execution of long running scripts is no longer slowed down.

Comment 23 errata-xmlrpc 2012-02-21 05:49:38 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-2012-0159.html