Bug 1733004 - memory leaks
Summary: memory leaks
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 30
Hardware: All
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Siteshwar Vashisht
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-07-25 01:34 UTC by 1014938109
Modified: 2019-11-28 10:58 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:


Attachments (Terms of Use)

Description 1014938109 2019-07-25 01:34:34 UTC
Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 1014938109 2019-07-25 01:43:36 UTC
Description of problem:


Memory leaks of bash:


How reproducible:


Steps to Reproduce:
1.Memory leaks detected by using the asan

we also used the valgrind to detect the memory leaks

Actual results:

==7878==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 10 byte(s) in 1 object(s) allocated from:
    #0 0xffff8cbe21db in __interceptor_malloc (/lib64/libasan.so.4+0xd31db)
    #1 0xaaaab977aaf3 in xmalloc (/usr/bin/bash+0x165af3)
    #2 0xaaaab969fe7f  (/usr/bin/bash+0x8ae7f)
    #3 0xaaaab96d9677 in execute_command_internal (/usr/bin/bash+0xc4677)
    #4 0xaaaab96a2cf3  (/usr/bin/bash+0x8dcf3)
    #5 0xaaaab96dacb3 in execute_command_internal (/usr/bin/bash+0xc5cb3)
    #6 0xaaaab9788443 in parse_and_execute (/usr/bin/bash+0x173443)
    #7 0xaaaab971d52f in command_substitute (/usr/bin/bash+0x10852f)
    #8 0xaaaab9728a17  (/usr/bin/bash+0x113a17)
    #9 0xaaaab972bbb7  (/usr/bin/bash+0x116bb7)
    #10 0xaaaab9735887  (/usr/bin/bash+0x120887)
    #11 0xaaaab96a0627  (/usr/bin/bash+0x8b627)
    #12 0xaaaab96d9677 in execute_command_internal (/usr/bin/bash+0xc4677)
    #13 0xaaaab96da6e3 in execute_command_internal (/usr/bin/bash+0xc56e3)
    #14 0xaaaab96de5c3 in execute_command (/usr/bin/bash+0xc95c3)
    #15 0xaaaab96da61f in execute_command_internal (/usr/bin/bash+0xc561f)
    #16 0xaaaab96de5c3 in execute_command (/usr/bin/bash+0xc95c3)
    #17 0xaaaab96da61f in execute_command_internal (/usr/bin/bash+0xc561f)
    #18 0xaaaab96d9a27 in execute_command_internal (/usr/bin/bash+0xc4a27)
    #19 0xaaaab96e04ff  (/usr/bin/bash+0xcb4ff)
    #20 0xaaaab96a1477  (/usr/bin/bash+0x8c477)
    #21 0xaaaab96d9677 in execute_command_internal (/usr/bin/bash+0xc4677)
    #22 0xaaaab9788443 in parse_and_execute (/usr/bin/bash+0x173443)
    #23 0xaaaab96c2fdb in execute_variable_command (/usr/bin/bash+0xadfdb)
    #24 0xaaaab96aa9ab in parse_command (/usr/bin/bash+0x959ab)
    #25 0xaaaab96aabb7 in read_command (/usr/bin/bash+0x95bb7)
    #26 0xaaaab96ab21b in reader_loop (/usr/bin/bash+0x9621b)
    #27 0xaaaab96a71af in main (/usr/bin/bash+0x921af)
    #28 0xffff8c947adf in __libc_start_main (/lib64/libc.so.6+0x20adf)
    #29 0xaaaab96a995b  (/usr/bin/bash+0x9495b)


==15303== HEAP SUMMARY:
==15303==     in use at exit: 449,533 bytes in 19,621 blocks
==15303==   total heap usage: 35,820 allocs, 16,199 frees, 921,773 bytes allocated
==15303== 
==15303== 5 bytes in 1 blocks are indirectly lost in loss record 51 of 2,659
==15303==    at 0x4866BC0: malloc (vg_replace_malloc.c:299)
==15303==    by 0x1964D3: xmalloc (xmalloc.c:112)
==15303==    by 0x14555B: read_token_word (parse.y:5085)
==15303==    by 0x14555B: read_token.constprop.8 (parse.y:3297)
==15303==    by 0x14784F: yylex (parse.y:2676)
==15303==    by 0x14784F: yyparse (y.tab.c:1835)
==15303==    by 0x13E2DF: parse_command (eval.c:262)
==15303==    by 0x13E41B: read_command (eval.c:306)
==15303==    by 0x13E693: reader_loop (eval.c:150)
==15303==    by 0x13D15B: main (shell.c:802)
==15303== 
==15303== 16 bytes in 1 blocks are indirectly lost in loss record 241 of 2,659
==15303==    at 0x4866BC0: malloc (vg_replace_malloc.c:299)
==15303==    by 0x1964D3: xmalloc (xmalloc.c:112)
==15303==    by 0x14C5CF: alloc_word_desc (make_cmd.c:96)
==15303==    by 0x145547: read_token_word (parse.y:5084)
==15303==    by 0x145547: read_token.constprop.8 (parse.y:3297)
==15303==    by 0x14784F: yylex (parse.y:2676)
==15303==    by 0x14784F: yyparse (y.tab.c:1835)
==15303==    by 0x13E2DF: parse_command (eval.c:262)
==15303==    by 0x13E41B: read_command (eval.c:306)
==15303==    by 0x13E693: reader_loop (eval.c:150)
==15303==    by 0x13D15B: main (shell.c:802)
==15303== 
==15303== 16 bytes in 1 blocks are indirectly lost in loss record 242 of 2,659
==15303==    at 0x4866BC0: malloc (vg_replace_malloc.c:299)
==15303==    by 0x1964D3: xmalloc (xmalloc.c:112)
==15303==    by 0x14C87B: make_word_list (make_cmd.c:183)
==15303==    by 0x14D03B: make_simple_command (make_cmd.c:557)
==15303==    by 0x148DEF: yyparse (parse.y:733)
==15303==    by 0x13E2DF: parse_command (eval.c:262)
==15303==    by 0x13E41B: read_command (eval.c:306)
==15303==    by 0x13E693: reader_loop (eval.c:150)
==15303==    by 0x13D15B: main (shell.c:802)
==15303== 
==15303== 16 bytes in 1 blocks are indirectly lost in loss record 243 of 2,659
==15303==    at 0x4866BC0: malloc (vg_replace_malloc.c:299)
==15303==    by 0x1964D3: xmalloc (xmalloc.c:112)
==15303==    by 0x14C87B: make_word_list (make_cmd.c:183)
==15303==    by 0x14D03B: make_simple_command (make_cmd.c:557)
==15303==    by 0x148E0F: yyparse (parse.y:735)
==15303==    by 0x13E2DF: parse_command (eval.c:262)
==15303==    by 0x13E41B: read_command (eval.c:306)
==15303==    by 0x13E693: reader_loop (eval.c:150)
==15303==    by 0x13D15B: main (shell.c:802)
==15303== 
==15303== 32 bytes in 1 blocks are indirectly lost in loss record 1,040 of 2,659
==15303==    at 0x4866BC0: malloc (vg_replace_malloc.c:299)
==15303==    by 0x1964D3: xmalloc (xmalloc.c:112)
==15303==    by 0x14CDC3: make_if_command (make_cmd.c:413)
==15303==    by 0x148583: yyparse (parse.y:1003)
==15303==    by 0x13E2DF: parse_command (eval.c:262)
==15303==    by 0x13E41B: read_command (eval.c:306)
==15303==    by 0x13E693: reader_loop (eval.c:150)
==15303==    by 0x13D15B: main (shell.c:802)
==15303== 
==15303== 64 bytes in 2 blocks are indirectly lost in loss record 1,363 of 2,659
==15303==    at 0x4866BC0: malloc (vg_replace_malloc.c:299)
==15303==    by 0x1964D3: xmalloc (xmalloc.c:112)
==15303==    by 0x14C92B: command_connect (make_cmd.c:212)
==15303==    by 0x149ACB: yyparse (parse.y:1112)
==15303==    by 0x13E2DF: parse_command (eval.c:262)
==15303==    by 0x13E41B: read_command (eval.c:306)
==15303==    by 0x13E693: reader_loop (eval.c:150)
==15303==    by 0x13D15B: main (shell.c:802)
==15303== 
==15303== 64 bytes in 2 blocks are indirectly lost in loss record 1,364 of 2,659
==15303==    at 0x4866BC0: malloc (vg_replace_malloc.c:299)
==15303==    by 0x1964D3: xmalloc (xmalloc.c:112)
==15303==    by 0x14C8EB: make_command (make_cmd.c:197)
==15303==    by 0x149ACB: yyparse (parse.y:1112)
==15303==    by 0x13E2DF: parse_command (eval.c:262)
==15303==    by 0x13E41B: read_command (eval.c:306)
==15303==    by 0x13E693: reader_loop (eval.c:150)
==15303==    by 0x13D15B: main (shell.c:802)
==15303== 
==15303== 96 bytes in 4 blocks are indirectly lost in loss record 2,001 of 2,659
==15303==    at 0x4866BC0: malloc (vg_replace_malloc.c:299)
==15303==    by 0x1964D3: xmalloc (xmalloc.c:112)
==15303==    by 0x14CF87: make_bare_simple_command (make_cmd.c:525)
==15303==    by 0x14D06F: make_simple_command (make_cmd.c:551)
==15303==    by 0x148DEF: yyparse (parse.y:733)
==15303==    by 0x13E2DF: parse_command (eval.c:262)
==15303==    by 0x13E41B: read_command (eval.c:306)
==15303==    by 0x13E693: reader_loop (eval.c:150)
==15303==    by 0x13D15B: main (shell.c:802)
==15303== 
==15303== 128 bytes in 4 blocks are indirectly lost in loss record 2,051 of 2,659
==15303==    at 0x4866BC0: malloc (vg_replace_malloc.c:299)
==15303==    by 0x1964D3: xmalloc (xmalloc.c:112)
==15303==    by 0x14CF7B: make_bare_simple_command (make_cmd.c:524)
==15303==    by 0x14D06F: make_simple_command (make_cmd.c:551)
==15303==    by 0x148DEF: yyparse (parse.y:733)
==15303==    by 0x13E2DF: parse_command (eval.c:262)
==15303==    by 0x13E41B: read_command (eval.c:306)
==15303==    by 0x13E693: reader_loop (eval.c:150)
==15303==    by 0x13D15B: main (shell.c:802)
==15303== 
==15303== 469 (32 direct, 437 indirect) bytes in 1 blocks are definitely lost in loss record 2,498 of 2,659
==15303==    at 0x4866BC0: malloc (vg_replace_malloc.c:299)
==15303==    by 0x1964D3: xmalloc (xmalloc.c:112)
==15303==    by 0x14C8EB: make_command (make_cmd.c:197)
==15303==    by 0x148583: yyparse (parse.y:1003)
==15303==    by 0x13E2DF: parse_command (eval.c:262)
==15303==    by 0x13E41B: read_command (eval.c:306)
==15303==    by 0x13E693: reader_loop (eval.c:150)
==15303==    by 0x13D15B: main (shell.c:802)
==15303== 
==15303== LEAK SUMMARY:
==15303==    definitely lost: 32 bytes in 1 blocks
==15303==    indirectly lost: 437 bytes in 17 blocks
==15303==      possibly lost: 0 bytes in 0 blocks
==15303==    still reachable: 449,064 bytes in 19,603 blocks
==15303==         suppressed: 0 bytes in 0 blocks
==15303== Reachable blocks (those to which a pointer was found) are not shown.
==15303== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==15303== 
==15303== For counts of detected and suppressed errors, rerun with: -v
==15303== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

Expected results:


Additional info:

Comment 2 Kamil Dudka 2019-07-25 08:19:02 UTC
Please provide self-contained steps to reproduce and name-version-release of the bash package.

Comment 3 1014938109 2019-07-25 14:09:56 UTC
We need to add the libasan.so.x to the bash, so we need to rebuild the rpm and then replace the bash in linux.

First:we need to rebuild the bash so that the libasan.so.x could be added to bash
1.setting environment variables
ulimit -v unlimited

2.replace gcc/g++
mv /usr/bin/g++  /usr/bin/g++_old
# vim /usr/bin/g++
Adding the content to /usr/bin/g++
#!/bin/bash
/usr/bin/g++_old -fsanitize=address -fsanitize-recover=address -U_FORTIFY_SOURCE -fno-omit-frame-pointer -fno-common "$@"
 
mv /usr/bin/gcc  /usr/bin/gcc_old
# vim /usr/bin/gcc
Adding the content to /usr/bin/gcc

[root@localhost SPECS]# cat /usr/bin/gcc
#!/bin/bash
/usr/bin/gcc_old -fsanitize=address -fsanitize-recover=address -U_FORTIFY_SOURCE -fno-omit-frame-pointer -fno-common "$@"

3.revise 
/usr/lib/rpm/find-debuginfo.sh
(adding the content below)
export ASAN_OPTIONS=abort_on_error=0:disable_coredump=0:detect_leaks=0
export LD_PRELOAD=/usr/lib64/libasan.so.4

4.adding environment variables
export ASAN_OPTIONS=detect_leaks=0:halt_on_error=0
 5.then build rpm
Rpmbuild -bb bash.rpm

Then: we need to use the rpm of bash builded  above

And then you can type any command, the libasan will be triggered and report the leaks.


The rpm used is the bash-4.4.23-7.


Thank you.


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