FS#45891 - [bash] script shows memory leak

Attached to Project: Arch Linux
Opened by Sijie Bu (butangmucat) - Tuesday, 04 August 2015, 09:00 GMT
Last edited by Bartłomiej Piotrowski (Barthalion) - Monday, 23 November 2015, 20:18 GMT
Task Type Bug Report
Category Upstream Bugs
Status Closed
Assigned To Bartłomiej Piotrowski (Barthalion)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

I saw this on the Red Hat bug tracker and reproduced on my Arch Linux installation. Bash is eating up memory when dealing with a special script.

The original bug report: https://bugzilla.redhat.com/show_bug.cgi?id=1245233

Additional info:

sijie@sijie-t900 ~ $ pacman -Q bash
bash 4.3.039-1

bash --version
GNU bash,版本 4.3.39(1)-release (x86_64-unknown-linux-gnu)

Steps to reproduce:

I simply followed the steps in the original Red Hat bug report.

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

sijie@sijie-t900 ~ $ 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 ]

sijie@sijie-t900 ~ $ ./test2.sh
memory consumption: 43244
memory consumption: 443468
This task depends upon

Closed by  Bartłomiej Piotrowski (Barthalion)
Monday, 23 November 2015, 20:18 GMT
Reason for closing:  Fixed
Additional comments about closing:  bash 4.3.042-4
Comment by Doug Newgard (Scimmia) - Tuesday, 04 August 2015, 13:42 GMT
Have you reported this upstream? Reporting it here isn't going to do much.
Comment by Rikard Falkeborn (Herk) - Saturday, 10 October 2015, 15:18 GMT
This is fixed on the development branch of Bash.

With https://aur.archlinux.org/packages/bash-devel-git/

[~]./test2.sh
memory consumption: 14888
memory consumption: 14888
./test2.sh: line 13: 26605 Terminated $(readlink /proc/$$/exe) loop.sh

Loading...