bash failed to start with valgrind

Masanari Iida <[email protected]>
Newsgroups gmane.comp.shells.bash.bugs
Message-ID <CALLJCT1d4ivay-sGt+Mc5+qs9KCTCPDMZ9pakZk3e4HTfO-T_g@mail.gmail.com>
Test with latest bash (commit 637f5c8696a6adc9b4519f1), x86_64,
I try to execute bash with valgrind,  it failed.

How to reproduce.
$  valgrind --mem-leak=full ./bash
malloc: variables.c:658: assertion botched
free: called with unallocated block argument
last command: (null)
Aborting...==208360==
==208360== Process terminating with default action of signal 6
(SIGABRT): dumping core
==208360==    at 0x49287D4: __pthread_kill_implementation (pthread_kill.c:44)
==208360==    by 0x48CF39D: raise (raise.c:26)
==208360==    by 0x48B6991: abort (abort.c:100)
==208360==    by 0x42D614: programming_error (error.c:162)
==208360==    by 0x4D4CB1: internal_free.isra.0 (malloc.c:963)
==208360==    by 0x42BCD7: initialize_shell_variables (variables.c:658)
==208360==    by 0x403F65: shell_initialize (shell.c:1963)
==208360==    by 0x40285F: main (shell.c:580)
==208360==
==208360== HEAP SUMMARY:
==208360==     in use at exit: 14,068 bytes in 60 blocks
==208360==   total heap usage: 81 allocs, 21 frees, 30,535 bytes allocated
==208360==
==208360== LEAK SUMMARY:
==208360==    definitely lost: 0 bytes in 0 blocks
==208360==    indirectly lost: 0 bytes in 0 blocks
==208360==      possibly lost: 0 bytes in 0 blocks
==208360==    still reachable: 14,068 bytes in 60 blocks
==208360==         suppressed: 0 bytes in 0 blocks
==208360== Reachable blocks (those to which a pointer was found) are not shown.
==208360== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==208360==
==208360== For lists of detected and suppressed errors, rerun with: -s
==208360== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
Aborted (core dumped)

I can reproduce this issue 100%.

(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>,
signo=signo@entry=6,
    no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x0000000004928843 in __pthread_kill_internal (threadid=<optimized
out>, signo=6)
    at pthread_kill.c:78
#2  0x00000000048cf39e in __GI_raise (sig=sig@entry=6) at
../sysdeps/posix/raise.c:26
#3  0x00000000048b6992 in __GI_abort () at abort.c:100
#4  0x000000000042d615 in programming_error (format=<optimized out>)
at error.c:162
#5  0x00000000004d4c26 in xbotch (s=<optimized out>,
file=file@entry=0x4f9cac "variables.c",
    line=line@entry=658, e=2, mem=0x4aaff20) at malloc.c:382
#6  0x00000000004d4cb2 in internal_free (mem=mem@entry=0x4aaff20,
    file=file@entry=0x4f9cac "variables.c", line=line@entry=658,
flags=1) at malloc.c:963
#7  0x00000000004d6005 in sh_free (mem=mem@entry=0x4aaff20,
    file=file@entry=0x4f9cac "variables.c", line=line@entry=658) at
malloc.c:1408
#8  0x00000000004779ba in sh_xfree (string=string@entry=0x4aaff20,
    file=file@entry=0x4f9cac "variables.c", line=line@entry=658) at
xmalloc.c:223
#9  0x000000000042bcd8 in initialize_shell_variables (env=<optimized
out>, privmode=0)
    at variables.c:658
#10 0x0000000000403f66 in shell_initialize () at shell.c:1963
#11 0x0000000000402860 in main (argc=1, argv=0x1ffefffbb8,
env=0x1ffefffbc8) at shell.c:580

Masanari
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.