Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.
This repository was archived by the owner on Jun 16, 2025. It is now read-only.

free(): invalid pointer traceback, possibly in sourcing (.) #582

Description

@rocky

Description of problem:

When I use kshdb, I can get an invalid free() traceback and core dump.

Ksh version:

version sh (AT&T Research) 93v-971-g4784bab

Steps to reproduce:

  1. Checkout kshdb:
$ git clone https://github.com/rocky/kshdb.git
  1. Configure it
$ cd kshdb
$ ksh autogen.sh
  1. Create a debugger startup profile:
echo "print hi there" > $HOME/.kshdbrc
  1. Run the debugger on an integration test
$ ./kshdb -L . test/example/dbg-test1.sh 
ksh debugger, kshdb, release 0.07dev

Copyright 2008-2011, 2018 Rocky Bernstein
This is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.

./kshdb[88]: .[28]: source: syntax error at line 295: `<<' unexpected
(/src/external-vcs/github/rocky/kshdb/test/example/dbg-test1.sh:22):
x=22
Evaluate unrecognized commands is on.
*** Error in `/usr/local/bin/ksh': free(): invalid pointer: 0x0000000000a9e330 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fe1f6b757e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7fe1f6b7e37a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7fe1f6b8253c]
/usr/local/bin/ksh(ast_free+0x22)[0x532828]
/usr/local/bin/ksh(b_dot_cmd+0x7dc)[0x41be5c]
/usr/local/bin/ksh(sh_exec+0x200f)[0x4bd1c9]
/usr/local/bin/ksh(sh_exec+0x4ed6)[0x4c0090]
/usr/local/bin/ksh(sh_exec+0x63b2)[0x4c156c]
/usr/local/bin/ksh(sh_exec+0x4e97)[0x4c0051]
/usr/local/bin/ksh(b_dot_cmd+0x6c1)[0x41bd41]
/usr/local/bin/ksh(sh_funct+0x2a2)[0x4c42e5]
/usr/local/bin/ksh(sh_exec+0x2b0a)[0x4bdcc4]
/usr/local/bin/ksh(sh_exec+0x4e97)[0x4c0051]
/usr/local/bin/ksh(b_dot_cmd+0x6c1)[0x41bd41]
/usr/local/bin/ksh(sh_funct+0x2a2)[0x4c42e5]
/usr/local/bin/ksh(sh_exec+0x2b0a)[0x4bdcc4]
/usr/local/bin/ksh(sh_exec+0x4e97)[0x4c0051]
/usr/local/bin/ksh(sh_exec+0x637a)[0x4c1534]
/usr/local/bin/ksh(sh_exec+0x4ed6)[0x4c0090]
/usr/local/bin/ksh(sh_exec+0x637a)[0x4c1534]
/usr/local/bin/ksh(sh_exec+0x4e97)[0x4c0051]
/usr/local/bin/ksh(sh_exec+0x5e23)[0x4c0fdd]
/usr/local/bin/ksh(sh_exec+0x4e97)[0x4c0051]
/usr/local/bin/ksh(b_dot_cmd+0x6c1)[0x41bd41]
/usr/local/bin/ksh(sh_funct+0x2a2)[0x4c42e5]
/usr/local/bin/ksh(sh_exec+0x2b0a)[0x4bdcc4]
/usr/local/bin/ksh(sh_exec+0x4e97)[0x4c0051]
/usr/local/bin/ksh(sh_exec+0x5e23)[0x4c0fdd]
/usr/local/bin/ksh(sh_exec+0x4e97)[0x4c0051]
/usr/local/bin/ksh(sh_exec+0x5e23)[0x4c0fdd]
/usr/local/bin/ksh(sh_exec+0x4e97)[0x4c0051]
/usr/local/bin/ksh(sh_funscope_20120720+0xa03)[0x4c5724]
/usr/local/bin/ksh(sh_funct+0x2fd)[0x4c4340]
/usr/local/bin/ksh(sh_exec+0x2b0a)[0x4bdcc4]
/usr/local/bin/ksh(sh_exec+0x4e97)[0x4c0051]
/usr/local/bin/ksh(b_dot_cmd+0x6c1)[0x41bd41]
/usr/local/bin/ksh(sh_funct+0x2a2)[0x4c42e5]
/usr/local/bin/ksh(sh_exec+0x2b0a)[0x4bdcc4]
/usr/local/bin/ksh(sh_exec+0x4e97)[0x4c0051]
/usr/local/bin/ksh(sh_exec+0x637a)[0x4c1534]
/usr/local/bin/ksh(sh_exec+0x4e97)[0x4c0051]
/usr/local/bin/ksh(sh_funscope_20120720+0xa03)[0x4c5724]
/usr/local/bin/ksh(sh_funct+0x2fd)[0x4c4340]
/usr/local/bin/ksh(sh_exec+0x2b0a)[0x4bdcc4]
/usr/local/bin/ksh(sh_eval_20120720+0x2f4)[0x4c5e4e]
/usr/local/bin/ksh(sh_trap_20120720+0x301)[0x4572f1]
/usr/local/bin/ksh(sh_debug+0x514)[0x4b9c1b]
/usr/local/bin/ksh(sh_setlist+0x20a5)[0x484104]
/usr/local/bin/ksh(sh_exec+0x10ee)[0x4bc2a8]
/usr/local/bin/ksh(sh_exec+0x4e97)[0x4c0051]
/usr/local/bin/ksh(sh_eval_20120720+0x2f4)[0x4c5e4e]
/usr/local/bin/ksh(b_dot_cmd+0x75f)[0x41bddf]
/usr/local/bin/ksh(sh_exec+0x200f)[0x4bd1c9]
/usr/local/bin/ksh(sh_exec+0x4ed6)[0x4c0090]
/usr/local/bin/ksh(sh_eval_20120720+0x2f4)[0x4c5e4e]
/usr/local/bin/ksh(b_eval+0x145)[0x41b677]
/usr/local/bin/ksh(sh_exec+0x200f)[0x4bd1c9]
/usr/local/bin/ksh(sh_exec+0x4e97)[0x4c0051]
/usr/local/bin/ksh(sh_exec+0x5e23)[0x4c0fdd]
/usr/local/bin/ksh(exfile+0xe58)[0x4810e6]
/usr/local/bin/ksh(sh_main+0x1035)[0x480257]
/usr/local/bin/ksh(main+0x25)[0x4ac23f]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fe1f6b1e830]
======= Memory map: ========
00400000-005c4000 r-xp 00000000 08:15 22460                              /usr/local/bin/ksh
007c3000-007d1000 r--p 001c3000 08:15 22460                              /usr/local/bin/ksh
007d1000-007d7000 rw-p 001d1000 08:15 22460                              /usr/local/bin/ksh
007d7000-007df000 rw-p 00000000 00:00 0 
00979000-00b1a000 rw-p 00000000 00:00 0                                  [heap]
7fe1f0000000-7fe1f0021000 rw-p 00000000 00:00 0 
7fe1f0021000-7fe1f4000000 ---p 00000000 00:00 0 
7fe1f5f29000-7fe1f5f3f000 r-xp 00000000 08:15 504101                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7fe1f5f3f000-7fe1f613e000 ---p 00016000 08:15 504101                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7fe1f613e000-7fe1f613f000 rw-p 00015000 08:15 504101                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7fe1f613f000-7fe1f6afe000 r--p 00000000 08:15 7371                       /usr/lib/locale/locale-archive
7fe1f6afe000-7fe1f6cbe000 r-xp 00000000 08:15 504064                     /lib/x86_64-linux-gnu/libc-2.23.so
7fe1f6cbe000-7fe1f6ebe000 ---p 001c0000 08:15 504064                     /lib/x86_64-linux-gnu/libc-2.23.so
7fe1f6ebe000-7fe1f6ec2000 r--p 001c0000 08:15 504064                     /lib/x86_64-linux-gnu/libc-2.23.so
7fe1f6ec2000-7fe1f6ec4000 rw-p 001c4000 08:15 504064                     /lib/x86_64-linux-gnu/libc-2.23.so
7fe1f6ec4000-7fe1f6ec8000 rw-p 00000000 00:00 0 
7fe1f6ec8000-7fe1f6ecb000 r-xp 00000000 08:15 504087                     /lib/x86_64-linux-gnu/libdl-2.23.so
7fe1f6ecb000-7fe1f70ca000 ---p 00003000 08:15 504087                     /lib/x86_64-linux-gnu/libdl-2.23.so
7fe1f70ca000-7fe1f70cb000 r--p 00002000 08:15 504087                     /lib/x86_64-linux-gnu/libdl-2.23.so
7fe1f70cb000-7fe1f70cc000 rw-p 00003000 08:15 504087                     /lib/x86_64-linux-gnu/libdl-2.23.so
7fe1f70cc000-7fe1f71d4000 r-xp 00000000 08:15 504132                     /lib/x86_64-linux-gnu/libm-2.23.so
7fe1f71d4000-7fe1f73d3000 ---p 00108000 08:15 504132                     /lib/x86_64-linux-gnu/libm-2.23.so
7fe1f73d3000-7fe1f73d4000 r--p 00107000 08:15 504132                     /lib/x86_64-linux-gnu/libm-2.23.so
7fe1f73d4000-7fe1f73d5000 rw-p 00108000 08:15 504132                     /lib/x86_64-linux-gnu/libm-2.23.so
7fe1f73d5000-7fe1f73fb000 r-xp 00000000 08:15 504037                     /lib/x86_64-linux-gnu/ld-2.23.so
7fe1f75c4000-7fe1f75c8000 rw-p 00000000 00:00 0 
7fe1f75f9000-7fe1f75fa000 rw-p 00000000 00:00 0 
7fe1f75fa000-7fe1f75fb000 r--p 00025000 08:15 504037                     /lib/x86_64-linux-gnu/ld-2.23.so
7fe1f75fb000-7fe1f75fc000 rw-p 00026000 08:15 504037                     /lib/x86_64-linux-gnu/ld-2.23.so
7fe1f75fc000-7fe1f75fd000 rw-p 00000000 00:00 0 
7ffc331ec000-7ffc3320d000 rw-p 00000000 00:00 0                          [stack]
7ffc332c3000-7ffc332c6000 r--p 00000000 00:00 0                          [vvar]
7ffc332c6000-7ffc332c8000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Aborted (core dumped)

Actual results:

Expected results:

Additional info:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions