Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1264101 - memleaks
memleaks
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: bash (Show other bugs)
7.1
Unspecified Unspecified
medium Severity medium
: rc
: ---
Assigned To: Siteshwar Vashisht
Martin Kyral
: Patch
Depends On:
Blocks: 1380361
  Show dependency treegraph
 
Reported: 2015-09-17 10:00 EDT by Martin Kyral
Modified: 2017-08-01 16:32 EDT (History)
2 users (show)

See Also:
Fixed In Version: bash-4.2.46-26.el7
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1297843 (view as bug list)
Environment:
Last Closed: 2017-08-01 16:32:05 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
valgrind log for repr1 (472.69 KB, text/plain)
2015-09-22 05:29 EDT, Martin Kyral
no flags Details
valgrind log for repr4 (404.41 KB, text/plain)
2015-09-22 05:29 EDT, Martin Kyral
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2017:1931 normal SHIPPED_LIVE Moderate: bash security and bug fix update 2017-08-01 14:26:59 EDT

  None (edit)
Description Martin Kyral 2015-09-17 10:00:59 EDT
Description of problem:
The following scripts are making bash to leak memory (originally reproducers for ksh memleaks). Also, the scripts run significantly slower under bash than with ksh (may be caused by the leaks, though).

$ cat repr1.ksh
#!/usr/bin/ksh

function _hash {
        typeset w=([abc]=1 [def]=31534 [xyz]=42)
        print -u2 $w 2>&-
        # accessing the var will leak
}
function _array {
        typeset w=(1 31534 42)
        print -u2 $w 2>&-
        # unset w will prevent leak
}

pmap -x $$ |tail -1
for (( j=0; j<100; j++)); do
        for (( i=0; i<10000; i++)); do
               _hash
        done
        pmap -x $$ |tail -1
done
sleep 1

$ cat repr4.ksh
#!/usr/bin/ksh

function _hash {
        typeset w=([abc]=1 [def]=31534 [xyz]=42)
        print -u2 $w 2>&-
        # accessing the var will leak
}
function _array {
        typeset w=(1 31534 42)
        print -u2 $w 2>&-
        # unset w will prevent leak
}

pmap -x $$ |tail -1
for (( j=0; j<100; j++)); do
        for (( i=0; i<10000; i++)); do
               _array
        done
        pmap -x $$ |tail -1
done
sleep 1

Version-Release number of selected component (if applicable):
bash-4.2.46-19.el7

How reproducible:
Always


Steps to Reproduce:
1. run the scripts from description
2.
3.

Actual results:
Memory usage grows quickly:
$ bash repr1.ksh
total kB          115060    3152     252
total kB          117964    6096    3196
total kB          120868    8912    6012
total kB          123640   11724    8824
total kB          126412   14536   11636
^C
$ bash repr4.ksh
total kB          115060    3152     256
total kB          117964    6096    3200
total kB          120868    8912    6016
total kB          123640   11724    8828
total kB          126412   14536   11640
^C
$


Expected results:
Steady memory usage as is with ksh:
$ ksh repr1.ksh
total kB          116848    1728     292
total kB          116848    1860     312
total kB          116848    1860     312
total kB          116848    1860     312
total kB          116848    1860     312
total kB          116848    1860     312
total kB          116848    1860     312
total kB          116848    1860     312
total kB          116848    1860     312
total kB          116848    1860     312
^C
$ ksh repr4.ksh
total kB          116848    1720     288
total kB          116848    1852     308
total kB          116848    1852     308
total kB          116848    1852     308
total kB          116848    1852     308
total kB          116848    1852     308
total kB          116848    1852     308
total kB          116848    1852     308
total kB          116848    1852     308
total kB          116848    1852     308
total kB          116848    1852     308
total kB          116848    1852     308
total kB          116848    1852     308
^C



Additional info:
Comment 1 Martin Kyral 2015-09-22 05:29 EDT
Created attachment 1075752 [details]
valgrind log for repr1
Comment 2 Martin Kyral 2015-09-22 05:29 EDT
Created attachment 1075753 [details]
valgrind log for repr4
Comment 8 errata-xmlrpc 2017-08-01 16:32:05 EDT
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://access.redhat.com/errata/RHSA-2017:1931

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