From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18987 invoked by alias); 25 Dec 2011 11:38:13 -0000 Received: (qmail 18979 invoked by uid 22791); 25 Dec 2011 11:38:12 -0000 X-SWARE-Spam-Status: No, hits=-7.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 25 Dec 2011 11:37:53 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pBPBbqo2020559 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 25 Dec 2011 06:37:52 -0500 Received: from host2.jankratochvil.net (ovpn-116-60.ams2.redhat.com [10.36.116.60]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pBPBbk7g019292 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Sun, 25 Dec 2011 06:37:49 -0500 Date: Mon, 26 Dec 2011 11:28:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: Tom Tromey , Kevin Pouget Subject: [patch] Fix remote.c crash on gdbserver close (+fix py-finish-breakpoint.exp for gdbserver) [Re: [RFC] Python Finish Breakpoints] Message-ID: <20111225113745.GA16273@host2.jankratochvil.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-12/txt/msg00822.txt.bz2 Hi, with gdbserver as from http://sourceware.org/gdb/wiki/TestingGDB#Testing_gdbserver_in_a_native_configuration it will crash: (gdb) PASS: gdb.python/py-finish-breakpoint.exp: set FinishBP after the exit() continue Continuing. Child exited with status 0 GDBserver exiting [Inferior 1 (Remote target) exited normally] SimpleFinishBreakpoint out of scope ERROR: Process no longer exists Program terminated with signal 11, Segmentation fault. #0 0x00000000007d48b9 in serial_debug_p (scb=0x0) at serial.c:584 584 return scb->debug_p || global_serial_debug_p; (gdb) p scb $1 = (struct serial *) 0x0 (gdb) bt #0 in serial_debug_p (scb=0x0) at serial.c:584 #1 in serial_write (scb=0x0, str=0x7fff727e3300 "$z0,4008a3,1#93", len=15) at serial.c:427 #2 in putpkt_binary (buf=0x2a279b0 "z0,4008a3,1", cnt=11) at remote.c:6891 #3 in putpkt (buf=0x2a279b0 "z0,4008a3,1") at remote.c:6823 #4 in remote_remove_breakpoint (gdbarch=0x28e10f0, bp_tgt=0x2fb3d38) at remote.c:7749 #5 in target_remove_breakpoint (gdbarch=0x28e10f0, bp_tgt=0x2fb3d38) at target.c:2422 #6 in bkpt_remove_location (bl=0x2fb3cd0) at breakpoint.c:10967 #7 in remove_breakpoint_1 (bl=0x2fb3cd0, is=mark_uninserted) at breakpoint.c:2654 #8 in remove_breakpoint (bl=0x2fb3cd0, is=mark_uninserted) at breakpoint.c:2760 #9 in update_global_location_list (should_insert=0) at breakpoint.c:10539 #10 in delete_breakpoint (bpt=0x2f59290) at breakpoint.c:11392 #11 in bpfinishpy_out_of_scope (bpfinish_obj=0x7fdf3c9f8130) at ./python/py-finishbreakpoint.c:327 #12 in bpfinishpy_detect_out_scope_cb (b=0x2f59290, args=0x0) at ./python/py-finishbreakpoint.c:356 #13 in iterate_over_breakpoints (callback=0x65150d , data=0x0) at breakpoint.c:13385 #14 in bpfinishpy_handle_exit (inf=0x281d330) at ./python/py-finishbreakpoint.c:393 #15 in observer_inferior_exit_notification_stub (data=0x6516b1, args_data=0x7fff727e3740) at observer.inc:887 #16 in generic_observer_notify (subject=0x284f300, args=0x7fff727e3740) at observer.c:168 #17 in observer_notify_inferior_exit (inf=0x281d330) at observer.inc:912 #18 in exit_inferior_1 (inftoex=0x281d330, silent=1) at inferior.c:276 #19 in exit_inferior_silent (pid=42000) at inferior.c:305 #20 in discard_all_inferiors () at inferior.c:343 #21 in remote_close (quitting=0) at remote.c:2950 #22 in target_close (targ=0x1d19f80, quitting=0) at target.c:3387 #23 in unpush_target (t=0x1d19f80) at target.c:1024 #24 in remote_mourn_1 (target=0x1d19f80) at remote.c:7456 #25 in remote_mourn (ops=0x1d19f80) at remote.c:7449 #26 in target_mourn_inferior () at target.c:2747 #27 in handle_inferior_event (ecs=0x7fff727e3c30) at infrun.c:3408 #28 in wait_for_inferior () at infrun.c:2711 #29 in proceed (addr=18446744073709551615, siggnal=TARGET_SIGNAL_DEFAULT, step=0) at infrun.c:2276 #30 in continue_1 (all_threads=0) at infcmd.c:713 #31 in continue_command (args=0x0, from_tty=1) at infcmd.c:805 Reproducible with: ../gdbserver/gdbserver :1234 gdb.python/py-finish-breakpoint gdb -nx -x ~/.gdbinit -ex r --args ../gdb -nx -ex 'file gdb.python/py-finish-breakpoint' -ex 'target remote localhost:1234' -ex 'b test_exec_exit' -ex c -ex 'source gdb.python/py-finish-breakpoint.py' -ex 'python SimpleFinishBreakpoint(gdb.newest_frame())' -ex c I have seen this serial_debug_p crash in various GDB debugging cases but they were not well reproducible. I understand this bug is unrelated to gdb.python/py-finish-breakpoint.exp . I also tried to reorder remote_close a bit but this patch seems as the right one to me. The .exp patch fixes in fact an unrelated testcase but both happen with gdbserver and py-finish-breakpoint.exp. The testcase has been tested on x86_64-fedorarawhide-linux-gnu. Thanks, Jan gdb/ 2011-12-25 Jan Kratochvil * remote.c (remote_remove_breakpoint): Return 0 on NULL REMOTE_DESC. gdb/testsuite/ 2011-12-25 Jan Kratochvil * gdb.python/py-finish-breakpoint.exp (catch out of scope after exec): Make it unsupported with gdbserver. --- a/gdb/remote.c +++ b/gdb/remote.c @@ -7734,6 +7734,13 @@ remote_remove_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr = bp_tgt->placed_address; struct remote_state *rs = get_remote_state (); + if (remote_desc == NULL) + { + /* remote_close is being executed as our caller. Avoid error by + reporting successful removal of the breakpoint. */ + return 0; + } + if (remote_protocol_packets[PACKET_Z0].support != PACKET_DISABLE) { char *p = rs->buf; --- a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp +++ b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp @@ -262,4 +262,17 @@ if ![runto "test_exec_exit"] then { gdb_test_no_output "set var do_exit = 0" "switch to execve() test" gdb_test "python SimpleFinishBreakpoint(gdb.newest_frame())" "SimpleFinishBreakpoint init" "set FinishBP after the exec" gdb_test "catch exec" "Catchpoint.*\(exec\).*" "catch exec" -gdb_test "continue" "SimpleFinishBreakpoint out of scope.*" "catch out of scope after exec" \ No newline at end of file + +set test "catch out of scope after exec" +gdb_test_multiple "continue" $test { + -re "warning: Error inserting catchpoint \[0-9\]+: Your system does not support this type\[ \r\n\]+of catchpoint\\.\r\n.*\r\n$gdb_prompt $" { + if [is_remote target] { + unsupported $test + } else { + fail $test + } + } + -re "SimpleFinishBreakpoint out of scope\r\n$gdb_prompt $" { + pass $test + } +}