From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9811 invoked by alias); 20 Apr 2011 20:26:56 -0000 Received: (qmail 9801 invoked by uid 22791); 20 Apr 2011 20:26:55 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,TW_DB 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; Wed, 20 Apr 2011 20:26:41 +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 p3KKQZ5N007843; Wed, 20 Apr 2011 15:26:37 -0500 Received: from EUSAACMS0703.eamcs.ericsson.se ([169.254.2.159]) by eusaamw0706.eamcs.ericsson.se ([147.117.20.31]) with mapi; Wed, 20 Apr 2011 16:26:36 -0400 From: Marc Khouzam To: "'sami wagiaalla'" , "'Tom Tromey'" , "'gdb-patches@sourceware.org'" Date: Wed, 20 Apr 2011 20:26:00 -0000 Subject: Patch for non-stop remote assertion (was: RE: [patch] Support inferior events in python) Message-ID: References: <4D4C62FA.5080101@redhat.com> In-Reply-To: <4D4C62FA.5080101@redhat.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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-04/txt/msg00376.txt.bz2 > -----Original Message----- > From: sami wagiaalla [mailto:swagiaal@redhat.com]=20 > Sent: Friday, February 04, 2011 3:35 PM > To: Tom Tromey > Cc: gdb-patches@sourceware.org > Subject: Re: [patch] Support inferior events in python >=20 >=20 > > Sami> +2011-01-21 Sami Wagiaalla > > Sami> + Oguz Kayral > > > > This is ok. Thanks for persevering, and congratulations. > > > > Tom >=20 > Woho! :).. Thank you for all the guidance. Committing soon. Hi, I think I'm having trouble with this patch. With non-stop and extended-remote, I can no longer attach to a process. I get an assertion in the python part. What I think is happening is the following. In remote_notice_new_inferior() line 1527 of remote.c,=20 we find out for the first time about a thread on the remote. The call to remote_add_thread() will add this thread but will also trigger the notifications about a running thread. Still within remote_notice_new_inferior(), the very next line, inferior_ptid is updated to match the=20 new thread. It seems to be too late though. When the python code receives the notification of a thread resume, it uses the old inferior_ptid to find the arch and the assertion is triggered because inferior_ptid does not have the tid yet. One fix that seems to work is to update the inferior_ptid before calling remote_add_thread(). But I have no idea if this is safe or not (it does not cause any regressions). I posted the patch at the end of this mail. The stack trace of the assertion and and very simple example session below. #0 0xb786e422 in __kernel_vsyscall () #1 0xb7417651 in raise () from /lib/tls/i686/cmov/libc.so.6 #2 0xb741aa82 in abort () from /lib/tls/i686/cmov/libc.so.6 #3 0x0809d915 in dump_core () at ../../src/gdb/utils.c:1053 #4 0x0809dbd5 in internal_vproblem (problem=3D0x847da54, file=3D0x83bf29a = "../../src/gdb/thread.c", line=3D620,=20 fmt=3D0x83bf27c "%s: Assertion `%s' failed.", ap=3D0xbfaffc2c "\001\373= ;\b\227\362;\b") at ../../src/gdb/utils.c:1211 #5 0x0809dc31 in internal_verror (file=3D0x83bf29a "../../src/gdb/thread.c= ", line=3D620, fmt=3D0x83bf27c "%s: Assertion `%s' failed.",=20 ap=3D0xbfaffc2c "\001\373;\b\227\362;\b") at ../../src/gdb/utils.c:1236 #6 0x0809dc69 in internal_error (file=3D0x83bf29a "../../src/gdb/thread.c"= , line=3D620, string=3D0x83bf27c "%s: Assertion `%s' failed.") at ../../src/gdb/utils.c:1246 #7 0x081b79b6 in is_thread_state (ptid=3D..., state=3DTHREAD_EXITED) at ..= /../src/gdb/thread.c:620 #8 0x081b7a17 in is_exited (ptid=3D...) at ../../src/gdb/thread.c:633 #9 0x080a5143 in has_stack_frames () at ../../src/gdb/frame.c:1336 #10 0x081ce2f4 in get_current_arch () at ../../src/gdb/arch-utils.c:757 #11 0x08132b48 in python_on_resume (ptid=3D...) at ../../src/gdb/python/py-= inferior.c:103 #12 0x0809780b in observer_target_resumed_notification_stub (data=3D0x8132b= 36, args_data=3D0xbfaffd74) at ./observer.inc:423 #13 0x080970a0 in generic_observer_notify (subject=3D0x948f4e0, args=3D0xbf= affd74) at ../../src/gdb/observer.c:168 #14 0x08097895 in observer_notify_target_resumed (ptid=3D...) at ./observer= .inc:448 #15 0x081b7951 in set_running (ptid=3D..., running=3D1) at ../../src/gdb/th= read.c:610 #16 0x080e80ad in remote_add_thread (ptid=3D..., running=3D1) at ../../src/= gdb/remote.c:1487 #17 0x080e8232 in remote_notice_new_inferior (currthread=3D..., running=3D1= ) at ../../src/gdb/remote.c:1527 #18 0x080ea041 in remote_threads_info (ops=3D0x848a7e0) at ../../src/gdb/re= mote.c:2668 #19 0x080ecb10 in extended_remote_attach_1 (target=3D0x848a7e0, args=3D0x94= 4cdff "13303", from_tty=3D0) at ../../src/gdb/remote.c:4243 #20 0x080ecd7a in extended_remote_attach (ops=3D0x848a7e0, args=3D0x944cdff= "13303", from_tty=3D0) at ../../src/gdb/remote.c:4299 #21 0x081e02d0 in target_attach (args=3D0x944cdff "13303", from_tty=3D0) at= ../../src/gdb/target.c:3256 #22 0x081a3ea1 in attach_command (args=3D0x944cdff "13303", from_tty=3D0) a= t ../../src/gdb/infcmd.c:2475 Session to reproduce: > gdb.7.4=20 GNU gdb (GDB) 7.3.50.20110417-cvs (gdb) set target-async on (gdb) set pagination off (gdb) set non-stop on (gdb) target extended-remote :9999 Remote debugging using :9999 (gdb) attach 10283 Attached to process 10283 [New Thread 10283.10283] ../../src/gdb/thread.c:620: internal-error: is_thread_state: Assertion `tp'= failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Potential fix that causes no regressions. What do you think? The problem is in HEAD and 7_3 so a fix should go into both. 2011-04-19 Marc Khouzam * remote.c (remote_notice_new_inferior): Update the=20 inferior_ptid before calling remote_add_thread. ### Eclipse Workspace Patch 1.0 #P src Index: gdb/remote.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/remote.c,v retrieving revision 1.443 diff -u -r1.443 remote.c --- gdb/remote.c 20 Apr 2011 17:54:08 -0000 1.443 +++ gdb/remote.c 20 Apr 2011 20:15:19 -0000 @@ -1524,8 +1524,11 @@ thread_change_ptid (inferior_ptid, currthread); else { - remote_add_thread (currthread, running); + /* First update the inferior_ptid as it could + be used within the call to remote_add_thread + which triggers observer notifications */ inferior_ptid =3D currthread; + remote_add_thread (currthread, running); } return; }