Configuration Information [Automatically generated, do not change]:Machine: x86_64OS: linux-gnuCompiler: gccCompilation CFLAGS: -g -O2 -fdebug-prefix-map=/build/bash-SmNvvg/bash-5.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wno-parentheses -Wno-format-securityuname output: Linux pop-os 5.11.0-7614-generic #15~1618626693~20.10~ecb25cd-Ubuntu SMP Thu Apr 22 16:00:45 UTC x86_64 x86_64 x86_64 GNU/LinuxMachine Type: x86_64-pc-linux-gnu Bash Version: 5.0Patch Level: 17Release Status: release Description: Super simple script to reproduce the behavior: **`leak.sh`** ```bash #! /bin/bash echo "Am I leaking?" Execute under valgrind... ``` ```none $ valgrind ./leak.sh ==1365336== Memcheck, a memory error detector ==1365336== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==1365336== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info ==1365336== Command: ./leak.sh ==1365336== Am I leaking? ==1365336== ==1365336== HEAP SUMMARY: ==1365336== in use at exit: 50,076 bytes in 766 blocks ==1365336== total heap usage: 858 allocs, 92 frees, 59,487 bytes allocated ==1365336== ==1365336== LEAK SUMMARY: ==1365336== definitely lost: 12 bytes in 1 blocks ==1365336== indirectly lost: 0 bytes in 0 blocks ==1365336== possibly lost: 0 bytes in 0 blocks ==1365336== still reachable: 50,064 bytes in 765 blocks ==1365336== suppressed: 0 bytes in 0 blocks ==1365336== Rerun with --leak-check=full to see details of leaked memory ==1365336== ==1365336== For lists of detected and suppressed errors, rerun with: -s ==1365336== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) ``` If you change the script to use the dash, the default shell (sh) for Pop!_OS (and I assume all Debian distros), then it will run without leaking. Repeat-By: echo "#! /bin/bash echo 'Am I leaking?'" > leak.sh \ && chmod +x leak.sh \ && valgrind --leak-check=full ./leak.sh
Memory leak detected by Valgrind
Zachary Fields via Bug reports for the GNU Bourne Again SHell Sat, 12 Jun 2021 09:54:01 -0700
- Memory leak ... Zachary Fields via Bug reports for the GNU Bourne Again SHell
- Re: Mem... Chet Ramey