yanqi27 / core_analyzer

A power tool to debug memory-related issues
376 stars 72 forks source link

crash when typing heap /u 5 #62

Closed Celthi closed 2 years ago

Celthi commented 2 years ago
(gdb) heap /u 5
Input expression doesn't reference any heap memory
free(): invalid pointer

Fatal signal: Aborted
----- Backtrace -----
0xaaaaba8226e7 gdb_internal_backtrace_1
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdb/bt-utils.c:122
0xaaaaba8226e7 _Z22gdb_internal_backtracev
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdb/bt-utils.c:168
0xaaaaba91c06f handle_fatal_signal
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdb/event-top.c:904
0xffff8fa5e7db ???
0xffff8eeaf200 __pthread_kill_implementation
        ./nptl/pthread_kill.c:44
0xffff8ee6a67b __GI_raise
        ../sysdeps/posix/raise.c:26
0xffff8ee5712f __GI_abort
        ./stdlib/abort.c:79
0xffff8eea3307 __libc_message
        ../sysdeps/posix/libc_fatal.c:155
0xffff8eeb957b malloc_printerr
        ./malloc/malloc.c:5664
0xffff8eebb2c3 _int_free
        ./malloc/malloc.c:4439
0xffff8eebdc83 __GI___libc_free
        ./malloc/malloc.c:3391
0xaaaaba964603 _Z17heap_command_implPc
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdb/heap.c:278
0xaaaaba972c2b heap_command
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdb/heapcmd.c:29
0xaaaaba853283 _Z8cmd_funcP16cmd_list_elementPKci
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdb/cli/cli-decode.c:2514
0xaaaabab6347f _Z15execute_commandPKci
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdb/top.c:702
0xaaaaba91cfe3 _Z15command_handlerPKc
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdb/event-top.c:597
0xaaaaba91d373 _Z20command_line_handlerOSt10unique_ptrIcN3gdb13xfree_deleterIcEEE
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdb/event-top.c:800
0xaaaaba91dbc3 gdb_rl_callback_handler
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdb/event-top.c:229
0xaaaabac0ef07 rl_callback_read_char
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../readline/readline/callback.c:281
0xaaaaba91c293 gdb_rl_callback_read_char_wrapper_noexcept
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdb/event-top.c:187
0xaaaaba91da4b gdb_rl_callback_read_char_wrapper
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdb/event-top.c:204
0xaaaaba91be57 _Z19stdin_event_handleriPv
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdb/event-top.c:524
0xaaaabacfd483 gdb_wait_for_event
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdbsupport/event-loop.cc:700
0xaaaabacfd837 gdb_wait_for_event
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdbsupport/event-loop.cc:596
0xaaaabacfd837 _Z16gdb_do_one_eventv
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdbsupport/event-loop.cc:237
0xaaaaba9e2fbb start_event_loop
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdb/main.c:421
0xaaaaba9e2fbb captured_command_loop
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdb/main.c:481
0xaaaaba9e49a3 captured_main
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdb/main.c:1351
0xaaaaba9e49a3 _Z8gdb_mainP18captured_main_args
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdb/main.c:1366
0xaaaaba763c07 main
        /home/ubuntu/core_analyzer/build/gdb-12.1/build/../gdb/gdb.c:32
---------------------
A fatal error internal to GDB has been detected, further
debugging is not possible.  GDB will now terminate.

This is a bug, please report it.  For instructions, see:
<https://www.gnu.org/software/gdb/bugs/>.

Aborted (core dumped)
Celthi commented 2 years ago

It occurs to me we should not call free at https://github.com/yanqi27/core_analyzer/blob/master/src/heap.cpp#L278