From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22481 invoked by alias); 10 Dec 2010 21:24:12 -0000 Received: (qmail 22471 invoked by uid 22791); 10 Dec 2010 21:24:11 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from imr4.ericy.com (HELO imr4.ericy.com) (198.24.6.8) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 10 Dec 2010 21:24:05 +0000 Received: from eusaamw0706.eamcs.ericsson.se ([147.117.20.31]) by imr4.ericy.com (8.14.3/8.14.3/Debian-9.1ubuntu1) with ESMTP id oBALs4ZP031452; Fri, 10 Dec 2010 15:54:07 -0600 Received: from EUSAACMS0703.eamcs.ericsson.se ([169.254.1.63]) by eusaamw0706.eamcs.ericsson.se ([147.117.20.31]) with mapi; Fri, 10 Dec 2010 16:23:46 -0500 From: Marc Khouzam To: "gdb@sourceware.org" CC: "pedro@codesourcery.com" , "tromey@redhat.com" Date: Fri, 10 Dec 2010 21:24:00 -0000 Subject: segfault: what should happen when I remove an inferior that is running? Message-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-12/txt/msg00030.txt.bz2 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=20 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=20 Temporary breakpoint 2, main () at a.cc:9 9 f(); (gdb) inf inf Num Description Executable=20=20=20=20=20=20=20=20 * 2 process 30730 /home/lmckhou/testing/a.out=20 1 process 30726 /home/lmckhou/testing/a.out=20 (gdb) remove-inferior 1 (gdb) inf inf Num Description Executable=20=20=20=20=20=20=20=20 * 2 process 30730 /home/lmckhou/testing/a.out=20 (gdb) inf th * 2 process 30730 main () at a.cc:9 (gdb) n Segmentation fault (top-gdb) backtrace=20 #0 stop_wait_callback (lp=3D0x84b9e30, data=3D0x0) at ../../src/gdb/linux-= nat.c:2599 #1 0x080910c9 in iterate_over_lwps (filter=3D..., callback=3D0x80957d0 , data=3D0x0) at ../../src/gdb/linux-nat.c:1239 #2 0x08096f4b in linux_nat_wait_1 (ops=3D0x83f55d0, ptid=3D..., ourstatus= =3D0xbffff208, target_options=3D0) at ../../src/gdb/linux-nat.c:3587 #3 linux_nat_wait (ops=3D0x83f55d0, ptid=3D..., ourstatus=3D0xbffff208, ta= rget_options=3D0) at ../../src/gdb/linux-nat.c:3704 #4 0x081783cb in target_wait (ptid=3D..., status=3D0xbffff208, options=3D0= ) at ../../src/gdb/target.c:2219 #5 0x0814d037 in wait_for_inferior (treat_exec_as_sigtrap=3D0) at ../../sr= c/gdb/infrun.c:2553 #6 0x0814d37c in proceed (addr=3D4294967295, siggnal=3DTARGET_SIGNAL_DEFAU= LT, step=3D1) at ../../src/gdb/infrun.c:2088 #7 0x0813fd43 in step_once (skip_subroutines=3D1, single_inst=3D0, count= =3D, thread=3D2) at ../../src/gdb/infcmd.c:1031 #8 0x08141d9d in step_1 (skip_subroutines=3D1, single_inst=3D0, count_stri= ng=3D0x0) at ../../src/gdb/infcmd.c:880 #9 0x08058c8c in execute_command (p=3D0x83e03b9 "", from_tty=3D1) at ../..= /src/gdb/top.c:422 #10 0x0815d1ac in command_handler (command=3D0x83e03b8 "n") at ../../src/gd= b/event-top.c:498 #11 0x0815de42 in command_line_handler (rl=3D0x8491d60 "`\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=3D0x0) at ../.= ./src/gdb/event-top.c:178 #14 0x0815c7f9 in handle_file_event (data=3D...) at ../../src/gdb/event-loo= p.c:817 #15 0x0815bf9b in process_event () at ../../src/gdb/event-loop.c:399 #16 0x0815cec6 in gdb_do_one_event (data=3D0x0) at ../../src/gdb/event-loop= .c:464 #17 0x08156f23 in catch_errors (func=3D0x815cc50 , func_a= rgs=3D0x0, errstring=3D0x82d19ba "", mask=3D6) at ../../src/gdb/exceptions.c:518 #18 0x080d3504 in tui_command_loop (data=3D0x0) at ../../src/gdb/tui/tui-in= terp.c:171 #19 0x081577c3 in current_interp_command_loop () at ../../src/gdb/interps.c= :291 #20 0x0804ec5b in captured_command_loop (data=3D0x0) at ../../src/gdb/main.= c:227 #21 0x08156f23 in catch_errors (func=3D0x804ec50 , f= unc_args=3D0x0, errstring=3D0x82d19ba "", mask=3D6) at ../../src/gdb/exceptions.c:518 #22 0x0804fab4 in captured_main (data=3D0xbffff750) at ../../src/gdb/main.c= :910 #23 0x08156f23 in catch_errors (func=3D0x804edf0 , func_args= =3D0xbffff750, errstring=3D0x82d19ba "", mask=3D6) at ../../src/gdb/exceptions.c:518 #24 0x0804eb92 in gdb_main (args=3D0xbffff750) at ../../src/gdb/main.c:919 #25 0x0804eb53 in main (argc=3D1, argv=3D0xbffff814) at ../../src/gdb/gdb.c= :34