Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1321379

Summary: bash 4.1.2-33.el6_7.1 memory leak
Product: Red Hat Enterprise Linux 6 Reporter: Matt Kandoll <voidmaterial>
Component: bashAssignee: Siteshwar Vashisht <svashisht>
Status: CLOSED DUPLICATE QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.7CC: sobolev
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-12-21 05:47:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Matt Kandoll 2016-03-25 23:39:35 UTC
Description of problem:
Bash script memory utilization continually increases if bash internal pattern matching / substitution is used.

Version-Release number of selected component (if applicable):
[root@RHEL6-TEST mkandoll]# rpm -qi bash
Name        : bash                         Relocations: (not relocatable)
Version     : 4.1.2                             Vendor: Red Hat, Inc.
Release     : 33.el6_7.1                    Build Date: Mon 17 Aug 2015 03:51:51
Install Date: Fri 25 Mar 2016 04:26:05 PM MST      Build Host: x86-027.build.eng
Group       : System Environment/Shells     Source RPM: bash-4.1.2-33.el6_7.1.sr
Size        : 3142151                          License: GPLv3+
Signature   : RSA/8, Thu 20 Aug 2015 08:01:55 AM MST, Key ID 199e2f91fd431d51
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL         : http://www.gnu.org/software/bash
Summary     : The GNU Bourne Again shell


How reproducible:
Every time

Steps to Reproduce:
Reproduced using script:
[root@RHEL6-BASIC mkandoll]# cat test17.sh
#!/bin/bash

while /bin/true
do

        test="something1234"
        test=${test//[^a-zA-Z0-9_.]/}

done

Run script for some time using:
nohup ./test17.sh 2>&1 > /dev/null &

Watch using top.

Actual results:
Memory usage increases without bound.

Expected results:
Memory is allocated first time and saved for reuse later.

Additional info:
Reproduced on a test vm using Red Hat Enterprise Linux Server release 6.5 (Santiago) that I upgraded bash package to 33.el6_7.1.  Seeing this in production servers running Red Hat Enterprise Linux Server release 6.7 (Santiago).
Testing is not possible on production servers.

For a workaround I am rewriting scripts that utilize this specific substitution to use echo piped to tr.

Comment 2 sobolev 2016-03-28 11:31:17 UTC
Fixed in RHEL7 (BZ#1172214) - "Bash made a system call to allocate memory twice for the same purpose, which caused Bash to leak memory."
Patch (really stupid bug in bash 4.0-4.2):
--- bash-4.1/subst.c    2015-04-07 10:00:00.482931289 +0900
+++ bash-4.1/subst.c    2015-04-07 10:01:28.258111134 +0900
@@ -7039,8 +7039,6 @@

       ret = alloc_word_desc ();
       ret->word = temp1;
-      ret = alloc_word_desc ();
-      ret->word = temp1;
       if (temp1 && QUOTED_NULL (temp1) && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
        ret->flags |= W_QUOTED|W_HASQUOTEDNULL;
       return ret;

But RHEL6 still needs the patches applied.

Comment 3 sobolev 2016-08-15 10:21:25 UTC
Fixed in 4.1.2-35 (#1207042)
Maybe change status to resolved/fixed?

Comment 5 Siteshwar Vashisht 2016-12-21 05:47:53 UTC

*** This bug has been marked as a duplicate of bug 1207042 ***