Bug 29275 - core-file -> detach -> crash
Summary: core-file -> detach -> crash
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: corefiles (show other bugs)
Version: 11.1
: P2 normal
Target Milestone: 13.1
Assignee: Pedro Alves
URL:
Keywords:
: 30207 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-06-22 18:58 UTC by Pedro Alves
Modified: 2023-04-02 18:10 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pedro Alves 2022-06-22 18:58:53 UTC
Loading a core file under gdb, and then using "detach" to unload it, results in GDB crashing.  It crashes in the same way on current master and in the gdb 11 & 12 branches.

$ gdb -c ./core
GNU gdb (GDB) 13.0.50.20220622-git
...
Core was generated by `(... snip ...)'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fcce92ba2ab in ?? ()
[Current thread is 1 (LWP 3566803)]
(gdb) detach
No core file now.

Fatal signal: Segmentation fault
----- Backtrace -----
0x55e3dc868a6d gdb_internal_backtrace_1
        ../../src/gdb/bt-utils.c:122
0x55e3dc868b26 _Z22gdb_internal_backtracev
        ../../src/gdb/bt-utils.c:168
0x55e3dca7965a handle_fatal_signal
        ../../src/gdb/event-top.c:946
0x55e3dca79800 handle_sigsegv
        ../../src/gdb/event-top.c:1019
0x7f44863be41f ???
        /build/glibc-SzIz7B/glibc-2.31/nptl/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x55e3dcb432bf maybe_set_commit_resumed_all_targets
        ../../src/gdb/infrun.c:2899
0x55e3dcb438be _ZN29scoped_disable_commit_resumed5resetEv
        ../../src/gdb/infrun.c:3023
0x55e3dcb43a0b _ZN29scoped_disable_commit_resumed16reset_and_commitEv
        ../../src/gdb/infrun.c:3049
0x55e3dcb329cc _Z14detach_commandPKci
        ../../src/gdb/infcmd.c:2791
0x55e3dc8caa45 do_simple_func
        ../../src/gdb/cli/cli-decode.c:95
0x55e3dc8d02af _Z8cmd_funcP16cmd_list_elementPKci
        ../../src/gdb/cli/cli-decode.c:2514
0x55e3dce32b1e _Z15execute_commandPKci
        ../../src/gdb/top.c:699
0x55e3dca78dc1 _Z15command_handlerPKc
        ../../src/gdb/event-top.c:598
0x55e3dca792ee _Z20command_line_handlerOSt10unique_ptrIcN3gdb13xfree_deleterIcEEE
        ../../src/gdb/event-top.c:842
0x55e3dce6362d tui_command_line_handler
        ../../src/gdb/tui/tui-interp.c:278
0x55e3dca7848a gdb_rl_callback_handler
        ../../src/gdb/event-top.c:230
0x55e3dcf5a37b rl_callback_read_char
        ../../../src/readline/readline/callback.c:290
0x55e3dca782a6 gdb_rl_callback_read_char_wrapper_noexcept
        ../../src/gdb/event-top.c:188
0x55e3dca78354 gdb_rl_callback_read_char_wrapper
        ../../src/gdb/event-top.c:205
0x55e3dca78bc1 _Z19stdin_event_handleriPv
        ../../src/gdb/event-top.c:525
0x55e3dd09616b handle_file_event
        ../../src/gdbsupport/event-loop.cc:549
0x55e3dd09671d gdb_wait_for_event
        ../../src/gdbsupport/event-loop.cc:670
0x55e3dd095461 _Z16gdb_do_one_eventv
        ../../src/gdbsupport/event-loop.cc:210
0x55e3dcbc9b8b start_event_loop
        ../../src/gdb/main.c:413
0x55e3dcbc9cd6 captured_command_loop
        ../../src/gdb/main.c:473
0x55e3dcbcb759 captured_main
        ../../src/gdb/main.c:1335
0x55e3dcbcb7cb _Z8gdb_mainP18captured_main_args
        ../../src/gdb/main.c:1350
0x55e3dc74b6a5 main
        ../../src/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/>.

Segmentation fault (core dumped)
Comment 1 Pedro Alves 2022-06-22 18:59:11 UTC
Got patch.
Comment 2 Pedro Alves 2022-06-22 19:21:45 UTC
Fix posted here:
https://sourceware.org/pipermail/gdb-patches/2022-June/190259.html
Comment 3 Pedro Alves 2022-07-11 18:32:29 UTC
Merged to both master and gdb-12-branch.
Comment 4 Pedro Alves 2022-07-11 18:32:45 UTC
Fixed.
Comment 5 Simon Marchi 2023-04-02 18:10:34 UTC
*** Bug 30207 has been marked as a duplicate of this bug. ***