Bug 618393 - memory leak in bash reading files
Summary: memory leak in bash reading files
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: bash
Version: 5.5
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Roman Rakus
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-07-26 20:17 UTC by david ahern
Modified: 2018-11-14 14:45 UTC (History)
6 users (show)

Fixed In Version: bash-3.2-28.el5
Doc Type: Bug Fix
Doc Text:
Bash had a memory leak in the "read" builtin when the number of fields being read was not equal to the number of variables passed as arguments, causing a shell script crash. This is fixed to prevent a memory leak and shell script crash.
Clone Of:
Environment:
Last Closed: 2011-07-21 10:39:07 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
patch for the memleak (1.30 KB, patch)
2010-09-29 16:33 UTC, Roman Rakus
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2011:1073 0 normal SHIPPED_LIVE Low: bash security, bug fix, and enhancement update 2011-07-21 10:37:04 UTC

Description david ahern 2010-07-26 20:17:48 UTC
Description of problem:
Bash is leaking memory on redirected reads ultimately leading to the crash of the shell script.

Version-Release number of selected component (if applicable):
tested with RHEL5.4 and RHEL5.5 both of which are using version bash-3.2-24.el5

How reproducible:
100%

Steps to Reproduce:
1. create a text file with a number of lines in it. In my case it is a 2M file with 4100 lines. (nothing magical about my input file -- just text)

2. get the pid of the shell: echo $$

3. run the following:
for n in $(seq 1 1000); do
   while read line; do
     echo $line; 
   done < /tmp/input-file > /dev/null 
done

4. in a separate login run:
while [ 1 ]; do egrep 'VmSiz|VmRSS' /proc/<pid>/status; sleep 2; done


Actual results:
VmRSS increases with time and memory not freed until shell exits.

Expected results:
memory consumption is flat

Additional info:

Comment 2 Roman Rakus 2010-09-29 16:33:54 UTC
Created attachment 450520 [details]
patch for the memleak

This patch fixes the issue - it is backported bash40-033 official patch

Comment 3 Roman Rakus 2011-03-03 17:08:12 UTC
Fixed in bash-3.2-28.el5

Comment 6 Branislav Náter 2011-04-14 05:59:03 UTC
Bugfix was successfully verified on package bash-3.2-29.el5.x86_64 on all supported architectures (i386, x86_64, ia64, ppc, s390x).

No memory leak appears anymore, memory consumption is flat.

Comment 7 Misha H. Ali 2011-04-20 09:33:28 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Previously bash had a memory leak in the "read" builtin when the number of fields being read was not the same as the number of variables passed as arguments. Ultimately, this caused the shell script to crash. This is now fixed to remove the memory leak and prevent the shell script from crashing unexpectedly.

Comment 8 Misha H. Ali 2011-05-04 01:37:24 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-Previously bash had a memory leak in the "read" builtin when the number of fields being read was not the same as the number of variables passed as arguments. Ultimately, this caused the shell script to crash. This is now fixed to remove the memory leak and prevent the shell script from crashing unexpectedly.+Bash had a memory leak in the "read" builtin when the number of fields being read was not equal to the number of variables passed as arguments, causing a shell script crash. This is fixed to prevent a memory leak and shell script crash.

Comment 9 errata-xmlrpc 2011-07-21 10:39:07 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-1073.html


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