Memory leak in ash with script using "local" incorrectly

Bastian Bittorf bittorf at bluebottle.com
Thu Oct 29 14:17:27 UTC 2015


* Rafał Miłecki <zajec5 at gmail.com> [29.10.2015 07:29]:
> while loop. Minimal test-case:
> while [ 1 ]; do local foo=$(date); done
> BusyBox's ash never complained but it was leaking a memory.

i did some more testing with an OpenWrt-UML:
i=0;while :; do i=$(( i + 1 )); local foo=$(:); case "$i" in *'00') free; echo $i;; esac; done

[...]
             total         used         free       shared      buffers
Mem:         25880        24040         1840           52          628
-/+ buffers:              23412         2468
Swap:            0            0            0
93700
             total         used         free       shared      buffers
Mem:         25880        24048         1832           52          628
-/+ buffers:              23420         2460
Swap:            0            0            0
93800
             total         used         free       shared      buffers
Mem:         25880        24060         1820           52          628
-/+ buffers:              23432         2448
Swap:            0            0            0
93900
             total         used         free       shared      buffers
Mem:         25880        24068         1812           52          628
-/+ buffers:              23440         2440
Swap:            0            0            0
94000

<here the shell was killed>
but this was with (the patched) busybox 1.23.1
(for beeing complete, there is no leak when omitting the 'local ')

i will now test 1.24.1 stable

bye, bastian


More information about the busybox mailing list