This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

segfault: what should happen when I remove an inferior that is running?


Hi,

while testing a patch for an assert failure with -remove-inferior:
http://sourceware.org/ml/gdb-patches/2010-12/msg00148.html

I got a segfault because I mistakenly removed an inferior that
was still running.  The session and backtrace are below.

I gather removing a running inferior is not a good idea, but
I think we should protect GDB against that user mistake
somehow.

Any suggestions on how to handle this case?

Thanks

Marc


> gdb.7.2 /home/lmckhou/testing/a.out
GNU gdb (GDB) 7.2
(gdb) start
Temporary breakpoint 1 at 0x80484a9: file a.cc, line 9.
Starting program: /home/lmckhou/testing/a.out 

Temporary breakpoint 1, main () at a.cc:9
9           f();
(gdb) add-inferior -exec /home/lmckhou/testing/a.out
Added inferior 2
Reading symbols from /home/lmckhou/testing/a.out...done.
(gdb) inferior 2
[Switching to inferior 2 [process 0] (/home/lmckhou/testing/a.out)]
(gdb) start
Temporary breakpoint 2 at 0x80484a9: file a.cc, line 9. (2 locations)
Starting program: /home/lmckhou/testing/a.out 

Temporary breakpoint 2, main () at a.cc:9
9           f();
(gdb) inf inf
  Num  Description       Executable        
* 2    process 30730     /home/lmckhou/testing/a.out 
  1    process 30726     /home/lmckhou/testing/a.out 
(gdb) remove-inferior 1
(gdb) inf inf
  Num  Description       Executable        
* 2    process 30730     /home/lmckhou/testing/a.out 
(gdb) inf th
* 2 process 30730  main () at a.cc:9
(gdb) n
Segmentation fault


(top-gdb) backtrace 
#0  stop_wait_callback (lp=0x84b9e30, data=0x0) at ../../src/gdb/linux-nat.c:2599
#1  0x080910c9 in iterate_over_lwps (filter=..., callback=0x80957d0 <stop_wait_callback>, data=0x0) at ../../src/gdb/linux-nat.c:1239
#2  0x08096f4b in linux_nat_wait_1 (ops=0x83f55d0, ptid=..., ourstatus=0xbffff208, target_options=0) at ../../src/gdb/linux-nat.c:3587
#3  linux_nat_wait (ops=0x83f55d0, ptid=..., ourstatus=0xbffff208, target_options=0) at ../../src/gdb/linux-nat.c:3704
#4  0x081783cb in target_wait (ptid=..., status=0xbffff208, options=0) at ../../src/gdb/target.c:2219
#5  0x0814d037 in wait_for_inferior (treat_exec_as_sigtrap=0) at ../../src/gdb/infrun.c:2553
#6  0x0814d37c in proceed (addr=4294967295, siggnal=TARGET_SIGNAL_DEFAULT, step=1) at ../../src/gdb/infrun.c:2088
#7  0x0813fd43 in step_once (skip_subroutines=1, single_inst=0, count=<value optimized out>, thread=2) at ../../src/gdb/infcmd.c:1031
#8  0x08141d9d in step_1 (skip_subroutines=1, single_inst=0, count_string=0x0) at ../../src/gdb/infcmd.c:880
#9  0x08058c8c in execute_command (p=0x83e03b9 "", from_tty=1) at ../../src/gdb/top.c:422
#10 0x0815d1ac in command_handler (command=0x83e03b8 "n") at ../../src/gdb/event-top.c:498
#11 0x0815de42 in command_line_handler (rl=0x8491d60 "`\232w\bP\232w\b") at ../../src/gdb/event-top.c:702
#12 0x08233254 in rl_callback_read_char () at ../../src/readline/callback.c:205
#13 0x0815d21b in rl_callback_read_char_wrapper (client_data=0x0) at ../../src/gdb/event-top.c:178
#14 0x0815c7f9 in handle_file_event (data=...) at ../../src/gdb/event-loop.c:817
#15 0x0815bf9b in process_event () at ../../src/gdb/event-loop.c:399
#16 0x0815cec6 in gdb_do_one_event (data=0x0) at ../../src/gdb/event-loop.c:464
#17 0x08156f23 in catch_errors (func=0x815cc50 <gdb_do_one_event>, func_args=0x0, errstring=0x82d19ba "", mask=6)
    at ../../src/gdb/exceptions.c:518
#18 0x080d3504 in tui_command_loop (data=0x0) at ../../src/gdb/tui/tui-interp.c:171
#19 0x081577c3 in current_interp_command_loop () at ../../src/gdb/interps.c:291
#20 0x0804ec5b in captured_command_loop (data=0x0) at ../../src/gdb/main.c:227
#21 0x08156f23 in catch_errors (func=0x804ec50 <captured_command_loop>, func_args=0x0, errstring=0x82d19ba "", mask=6)
    at ../../src/gdb/exceptions.c:518
#22 0x0804fab4 in captured_main (data=0xbffff750) at ../../src/gdb/main.c:910
#23 0x08156f23 in catch_errors (func=0x804edf0 <captured_main>, func_args=0xbffff750, errstring=0x82d19ba "", mask=6)
    at ../../src/gdb/exceptions.c:518
#24 0x0804eb92 in gdb_main (args=0xbffff750) at ../../src/gdb/main.c:919
#25 0x0804eb53 in main (argc=1, argv=0xbffff814) at ../../src/gdb/gdb.c:34


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]