Bug 1264101 - memleaks
Summary: memleaks
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: bash
Version: 7.1
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Siteshwar Vashisht
QA Contact: Martin Kyral
URL:
Whiteboard:
Depends On:
Blocks: 1380361
TreeView+ depends on / blocked
 
Reported: 2015-09-17 14:00 UTC by Martin Kyral
Modified: 2017-08-01 20:32 UTC (History)
2 users (show)

Fixed In Version: bash-4.2.46-26.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1297843 (view as bug list)
Environment:
Last Closed: 2017-08-01 20:32:05 UTC


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


Links
System 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 18:26:59 UTC

Description Martin Kyral 2015-09-17 14:00:59 UTC
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 09:29:21 UTC
Created attachment 1075752 [details]
valgrind log for repr1

Comment 2 Martin Kyral 2015-09-22 09:29:47 UTC
Created attachment 1075753 [details]
valgrind log for repr4

Comment 8 errata-xmlrpc 2017-08-01 20:32:05 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://access.redhat.com/errata/RHSA-2017:1931


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