Description of problem: Anon memory grows when functions make use of hashes (associative arrays) or arrays Version-Release number of selected component (if applicable): ksh-20100202-1.el5_5.1 Name : ksh Relocations: (not relocatable) Version : 20100202 Vendor: Red Hat, Inc. Release : 1.el5_5.1 Build Date: Wed 25 Aug 2010 07:51:34 AM UTC Install Date: Thu 24 Mar 2011 09:25:54 AM UTC Build Host: x86-012.build.bos.redhat.com Group : Applications/Shells Source RPM: ksh-20100202-1.el5_5.1.src.rpm Size : 3267867 License: Common Public License Version 1.0 Signature : DSA/SHA1, Thu 09 Sep 2010 03:21:24 PM UTC, Key ID 5326810137017186 Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> URL : http://www.kornshell.com/ Summary : The Original ATT Korn Shell Version AJM 93t+ 2010-02-02 How reproducible: #!/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 } print ${.sh.version} 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 Steps to Reproduce: start script. Actual results: Version AJM 93t+ 2010-06-21 total kB 73072 1296 216 total kB 80432 8712 7572 total kB 87856 16140 15000 total kB 95280 23556 22416 total kB 102704 30980 29840 total kB 110128 38408 37268 Expected results: anon memory does not grow Additional info:
reproducible
This problem occurs also in RHEL 5.9 and 6.2: more /etc/redhat-release Red Hat Enterprise Linux Server release 6.2 (Santiago) Name : ksh Relocations: (not relocatable) Version : 20100621 Vendor: CentOS Release : 12.el6_2.1 Build Date: Fri 06 Jan 2012 04:22:02 PM CET Install Date: Tue 12 Jun 2012 02:56:09 PM CEST Build Host: c6b18n1.dev.centos.org Group : System Environment/Shells Source RPM: ksh-20100621-12.el6_2.1.src.rpm Size : 1548708 License: CPL Signature : RSA/SHA1, Fri 06 Jan 2012 06:11:35 PM CET, Key ID 0946fca2c105b9de Packager : CentOS BuildSystem <http://bugs.centos.org> URL : http://www.kornshell.com/ Summary : The Original ATT Korn Shell Description :
Any ideas for workarounds? Look like the used syntax is not compatible with pdksh, which I considered to use in exchange.
(In reply to comment #2) > This problem occurs also in RHEL 5.9 and 6.2 This problem occurs in all ksh versions I've tested - from very old ksh versions (2008-02-02) to latest upstream alpha version (2013-02-22). I'm testing a patch already. (In reply to comment #3) > Any ideas for workarounds? Except calling the unset, there is no known workaround.
unset will not work with hashes (-A) e.g.: hash=([ind1]=val1 [ind2]=val2) only with arrays
Created attachment 710526 [details] patch to fix this
The customer is willing to test, can we hand out a testpackage?
Tested Test Package with script: Mem leak not completly solved. After some loops, significant slowdown in execution. Mem Leak even worse with hash function as in first example. function nil { false } print ${.sh.version} pmap -x $$ |tail -1 for (( j=0; j<100; j++)); do a=$SECONDS for (( i=0; i<10000; i++)); do nil done ((b=SECONDS-a)) printf "%3.4f " $b pmap -x $$ |tail -1 done Result: Version AJM 93t+ 2010-06-21 total kB 106880 1512 232 0.0713 total kB 106880 1580 252 0.0683 total kB 106880 1580 252 0.0755 total kB 106880 1580 252 0.0694 total kB 106880 1580 252 0.0759 total kB 106880 1580 252 0.0709 total kB 106880 1580 252 0.0686 total kB 106880 1580 252 0.0689 total kB 106880 1580 252 0.0684 total kB 106880 1584 256 0.0685 total kB 106880 1584 256 0.0691 total kB 106880 1584 256 0.0771 total kB 106880 1584 256 0.0715 total kB 106880 1584 256 0.0694 total kB 106880 1584 256 0.0693 total kB 106880 1584 256 0.0716 total kB 106880 1584 256 0.0727 total kB 106880 1584 256 0.0692 total kB 106880 1584 256 0.0690 total kB 106880 1584 256 0.0683 total kB 106880 1584 256 0.0681 total kB 106880 1584 256 0.0691 total kB 106880 1584 256 0.0729 total kB 106880 1584 256 0.0698 total kB 106880 1584 256 0.0684 total kB 106880 1584 256 0.0678 total kB 106880 1584 256 0.0686 total kB 106880 1584 256 0.0682 total kB 106880 1588 260 0.0691 total kB 106880 1588 260 0.0692 total kB 106880 1588 260 0.0692 total kB 106880 1588 260 0.0690 total kB 106880 1588 260 0.0686 total kB 106880 1588 260 0.0686 total kB 106880 1588 260 0.0685 total kB 106880 1588 260 0.0681 total kB 106880 1588 260 0.1020 total kB 106880 1588 260 0.1246 total kB 106880 1588 260 0.1136 total kB 106880 1588 260 0.1092 total kB 106880 1588 260 0.1080 total kB 106880 1588 260 ..
This request was evaluated by Red Hat Product Management for inclusion in a Red Hat Enterprise Linux release. Product Management has requested further review of this request by Red Hat Engineering, for potential inclusion in a Red Hat Enterprise Linux release for currently deployed products. This request is not yet committed for inclusion in a release.
The issue of the customer is fixed by the testpackage.
Does this patch also resolve the issue in RHEL 6? https://bugzilla.redhat.com/show_bug.cgi?id=921455
Yes and no. These bugs are a little messy. Bug for rhel 5 is in fact 2 (absolutely unrelated) bugs in one, for which we have two reproducers. Both of them are fixed in rhel5. The rhel6 bug is in fact 3 (absolutely unrelated) bugs with 3 reproducers. The first two are the same. So this patch will work and fix them. The third one is different and won't be fixed by this patch. We don't have patch for that reproducer yet.
added fix for the remaining reproducer from rhel6 clone bug
Created attachment 767425 [details] patch to fix this v2
Created attachment 767886 [details] patch to fix this v3
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. http://rhn.redhat.com/errata/RHBA-2013-1351.html