Reputation: 2683
I've been using gdb
for years but have not seen this behavior before.
To debug a SIGABRT
coming from a double free()
somewhere in the program, I've set a watch point on the pointer to the buffer. Now when I run the program again, gdb 'stops' as if I pressed ctrl-Z or it received SIGSTOP.
Any idea what's going on there and how do I avoid it?
# gdb --version
GNU gdb (GDB) Red Hat Enterprise Linux 8.2-6.el8
# uname -a
Linux Centos8 4.18.0-147.el8.x86_64 #1 SMP Wed Dec 4 21:51:45 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
The error:
(gdb) run
free(): invalid pointer
Program received signal SIGABRT, Aborted.
0x00007ffff6ad48df in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x00007ffff6ad48df in raise () from /lib64/libc.so.6
#1 0x00007ffff6abecf5 in abort () from /lib64/libc.so.6
#2 0x00007ffff6b17c17 in __libc_message () from /lib64/libc.so.6
#3 0x00007ffff6b1e53c in malloc_printerr () from /lib64/libc.so.6
#4 0x00007ffff6b2210e in free_check.part () from /lib64/libc.so.6
#5 0x00007ffff7bbde99 in MyProgram::parseTSPayload (this=0x6165b0) at MyProgram.cpp:284
...
#8 0x0000000000401b4c in main (argc=6, argv=0x7fffffffea28) at MyProgram.cpp:169
(gdb) f 5
#5 0x00007ffff7bbde99 in MyProgram::parseTSPayload (this=0x6165b0) at MyProgram.cpp:284
284 delete [] mpPESBuf;
Set watchpoint:
(gdb) watch mpPESBuf
Hardware watchpoint 2: mpPESBuf
(gdb) info watch
Num Type Disp Enb Address What
2 hw watchpoint keep y mpPESBuf
Now when I run the program again, gdb 'stops' as if I pressed ctrl-Z or it received SIGSTOP:
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: MyProgram
[1]+ Stopped gdb MyProgram
# fg
gdb MyProgram
Error in re-setting breakpoint 2: No symbol "mpPESBuf" in current context.
Error in re-setting breakpoint 2: No symbol "mpPESBuf" in current context.
Error in re-setting breakpoint 2: No symbol "mpPESBuf" in current context.
warning: Loadable section ".note.gnu.property" outside of ELF segments
warning: Loadable section ".note.gnu.property" outside of ELF segments
[1]+ Stopped gdb MyProgram
# fg
gdb MyProgram
Error in re-setting breakpoint 2: No symbol "mpPESBuf" in current context.
[PID 687305] MyProgram Version 1.1-18
Built 2020.11.24-11:43:08. Launched 2020-11-24 11:56:17.
free(): invalid pointer
Program received signal SIGABRT, Aborted.
0x00007ffff6ad48df in raise () from /lib64/libc.so.6
Upvotes: 0
Views: 238
Reputation: 4801
This is a bug in GDB that was fixed with this commit:
https://sourceware.org/legacy-ml/gdb-patches/2019-05/msg00361.html
This commit was in GDB 9, and you are using 8.2. You'll need to update your version of GDB in order to avoid this issue.
Upvotes: 1