Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1245233 - bash script shows memory leak
Summary: bash script shows memory leak
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 22
Hardware: All
OS: Linux
high
medium
Target Milestone: ---
Assignee: Ondrej Oprala
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-07-21 14:19 UTC by Martin Kyral
Modified: 2016-02-01 02:10 UTC (History)
3 users (show)

Fixed In Version: 4.3.42-1.fc21
Doc Type: Bug Fix
Doc Text:
Clone Of: 126161
Environment:
Last Closed: 2015-08-05 22:25:06 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Martin Kyral 2015-07-21 14:19:58 UTC
This ancient bug has been reintroduced in fedora:

$ cat loop.sh
#!/bin/bash
run() { local -a A=(); local -a A=(); }
while :; do run; done

$ cat test2.sh
#!/bin/bash
$(readlink /proc/$$/exe) loop.sh &
SHPID=$!
sleep 1
MEM=$(ps p $SHPID o "%z" | grep -v VSZ)
echo "memory consumption: $MEM"
sleep 15
MEM2=$(ps p $SHPID o "%z" | grep -v VSZ)
kill $SHPID
echo "memory consumption: $MEM2"
#compare memory consumption
[ $MEM -eq $MEM2 ]

$ bash test2.sh
memory consumption: 130292
memory consumption: 373304
$

In both RHEL6 and RHEL7 the test passes.

Version:
bash-4.3.39-3.fc22

+++ This bug was initially created as a clone of Bug #126161 +++

[root@localhost root]# bash --version
GNU bash, version 2.05b.0(1)-release (i386-redhat-linux-gnu)
Copyright (C) 2002 Free Software Foundation, Inc.

For testing purposes he uses:

---------------
#!/bin/bash
run() { local -a A=(); local -a A=(); }
while :; do run; done
---------------

This routine is eating up memory, which shows clearly 
in 'cat /proc/meminfo' or 'top'.

--- Additional comment from Bernd Schmidt on 2004-06-16 17:31:58 EDT ---

When make_local_variable finds an existing variable with the same name, it is
reused.  However, we never call array_dispose to free array data.  This patch
adds centralized freeing of all data for a reused local variable.

Comment 1 Fedora Update System 2015-08-03 10:15:04 UTC
bash-4.3.39-6.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/bash-4.3.39-6.fc21

Comment 2 Fedora Update System 2015-08-03 10:15:12 UTC
bash-4.3.39-6.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/bash-4.3.39-6.fc22

Comment 3 Fedora Update System 2015-08-03 10:15:20 UTC
bash-4.3.39-6.fc23 has been submitted as an update for Fedora 23.
https://admin.fedoraproject.org/updates/bash-4.3.39-6.fc23

Comment 4 Fedora Update System 2015-08-03 16:52:04 UTC
Package bash-4.3.39-6.fc23:
* should fix your issue,
* was pushed to the Fedora 23 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing bash-4.3.39-6.fc23'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-12688/bash-4.3.39-6.fc23
then log in and leave karma (feedback).

Comment 5 Fedora Update System 2015-08-05 22:25:06 UTC
bash-4.3.39-6.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 6 Fedora Update System 2015-08-10 10:03:52 UTC
bash-4.3.39-6.fc23 has been pushed to the Fedora 23 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 7 Fedora Update System 2015-08-18 14:07:16 UTC
bash-4.3.42-1.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/bash-4.3.42-1.fc21

Comment 8 Fedora Update System 2015-08-18 14:07:23 UTC
bash-4.3.42-1.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/bash-4.3.42-1.fc22

Comment 9 Fedora Update System 2015-08-18 14:07:36 UTC
bash-4.3.42-1.fc23 has been submitted as an update for Fedora 23.
https://admin.fedoraproject.org/updates/bash-4.3.42-1.fc23

Comment 10 Fedora Update System 2015-09-01 03:36:35 UTC
bash-4.3.42-1.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.

Comment 11 Fedora Update System 2015-09-04 05:19:29 UTC
bash-4.3.42-1.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.

Comment 12 Fedora Update System 2015-09-04 11:49:23 UTC
bash-4.3.42-1.fc21 has been pushed to the Fedora 21 stable repository. If problems still persist, please make note of it in this bug report.


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