Bug 1746101

Summary: memory leak in bash
Product: [Fedora] Fedora Reporter: Susan LoVerso <sjlv64>
Component: bashAssignee: Siteshwar Vashisht <svashisht>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 32CC: admiller, gabriel, kasal, kdudka, svashisht
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-25 17:33:16 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 Susan LoVerso 2019-08-27 16:20:12 UTC
Description of problem:
A slight variation on bug 1241533, a simple 'test' and exit of bash is showing memory leaks in bash in valgrind. We use the 'test' to short-circuit parts of our test suite in certain situations. It can be distilled down to the simple script below.


Version-Release number of selected component (if applicable):
GNU bash, version 4.4.12(1)-release (x86_64-redhat-linux-gnu)


How reproducible:
100%


Steps to Reproduce:
1. Create a bash script containing the following two lines:
#! /bin/bash
test "1" = "1" && exit 0
2. Run valgrind with: valgrind --leak-check=full <script>
3. See that valgrind detects memory leaks.

Actual results:
==83267== Memcheck, a memory error detector
==83267== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==83267== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==83267== Command: /tmp/bash-bug.sh
==83267== 
==83267== 
==83267== HEAP SUMMARY:
==83267==     in use at exit: 44,607 bytes in 635 blocks
==83267==   total heap usage: 790 allocs, 155 frees, 53,158 bytes allocated
==83267== 
==83267== 72 (32 direct, 40 indirect) bytes in 1 blocks are definitely lost in loss record 318 of 341
==83267==    at 0x4C2DB6B: malloc (vg_replace_malloc.c:299)
==83267==    by 0x18F07D: xmalloc (in /usr/bin/bash)
==83267==    by 0x14827A: make_bare_simple_command (in /usr/bin/bash)
==83267==    by 0x148355: make_simple_command (in /usr/bin/bash)
==83267==    by 0x142EAA: yyparse (in /usr/bin/bash)
==83267==    by 0x1397D5: parse_command (in /usr/bin/bash)
==83267==    by 0x1398D7: read_command (in /usr/bin/bash)
==83267==    by 0x139AB6: reader_loop (in /usr/bin/bash)
==83267==    by 0x13866F: main (in /usr/bin/bash)
==83267== 
==83267== LEAK SUMMARY:
==83267==    definitely lost: 32 bytes in 1 blocks
==83267==    indirectly lost: 40 bytes in 2 blocks
==83267==      possibly lost: 0 bytes in 0 blocks
==83267==    still reachable: 44,535 bytes in 632 blocks
==83267==         suppressed: 0 bytes in 0 blocks
==83267== Reachable blocks (those to which a pointer was found) are not shown.
==83267== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==83267== 
==83267== For counts of detected and suppressed errors, rerun with: -v
==83267== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)


Expected results:
Output showing no leaks like:
==82963== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)


Additional info:

Comment 1 Susan LoVerso 2019-09-03 18:26:30 UTC
It should be noted that adding in a no-op to the script avoids the memory leak. This 3 line script works with valgrind:
#! /bin/dash
date > /dev/null
test "1" = "1" && exit 0

Comment 2 Susan LoVerso 2019-09-05 13:43:51 UTC
(In reply to Susan LoVerso from comment #1)
> It should be noted that adding in a no-op to the script avoids the memory
> leak. This 3 line script works with valgrind:
> #! /bin/dash
> date > /dev/null
> test "1" = "1" && exit 

Sorry I did not notice that the script was using /bin/dash (I've been playing around with a lot of different things trying to find a workaround).
The no-op does NOT make this pass with /bin/bash.

Comment 3 Ben Cotton 2020-02-11 17:43:25 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 32 development cycle.
Changing version to 32.

Comment 4 Fedora Program Management 2021-04-29 16:59:39 UTC
This message is a reminder that Fedora 32 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 32 on 2021-05-25.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '32'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 32 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 5 Ben Cotton 2021-05-25 17:33:16 UTC
Fedora 32 changed to end-of-life (EOL) status on 2021-05-25. Fedora 32 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.