From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21686 invoked by alias); 9 Jul 2010 19:57:48 -0000 Received: (qmail 21674 invoked by uid 22791); 9 Jul 2010 19:57:47 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_MIME_NO_TEXT,T_RP_MATCHES_RCVD,T_TVD_MIME_NO_HEADERS 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; Fri, 09 Jul 2010 19:57:43 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o69JvfeN006401 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 9 Jul 2010 15:57:42 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o69JvfIJ008227; Fri, 9 Jul 2010 15:57:41 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o69Jve7Q021879; Fri, 9 Jul 2010 15:57:40 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 5C8DB37818E; Fri, 9 Jul 2010 13:57:40 -0600 (MDT) From: Tom Tromey To: gdb-patches@sourceware.org Subject: [Oleg Nesterov] PATCH? gdb remote.c: readchar() should pop_target() if SERIAL_ERROR? Date: Fri, 09 Jul 2010 19:57:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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: 2010-07/txt/msg00188.txt.bz2 --=-=-= Content-length: 313 I am forwarding this from the archer list because I think this report is reasonably complete -- I couldn't really improve on it. Please comment on this patch. I don't know this area of gdb well. If the enclosed has insufficient information, please contact me and I will get whatever is needed. Thanks. Tom --=-=-= Content-Type: message/rfc822 Content-Disposition: inline Content-length: 3269 X-From-Line: tromey Thu Jul 1 19:15:10 2010 Return-Path: onestero@redhat.com Received: from opsy [127.0.0.1] by opsy with IMAP (fetchmail-6.3.9) for (single-drop); Thu, 01 Jul 2010 19:15:10 -0600 (MDT) Received: from zmta01.collab.prod.int.phx2.redhat.com (LHLO zmta01.collab.prod.int.phx2.redhat.com) (10.5.5.31) by mail05.corp.redhat.com with LMTP; Thu, 1 Jul 2010 21:14:50 -0400 (EDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by zmta01.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id F40909316E; Thu, 1 Jul 2010 21:14:49 -0400 (EDT) Received: from zmta01.collab.prod.int.phx2.redhat.com ([127.0.0.1]) by localhost (zmta01.collab.prod.int.phx2.redhat.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mZ4OmIMGAFjd; Thu, 1 Jul 2010 21:14:49 -0400 (EDT) Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by zmta01.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id E1BE093168; Thu, 1 Jul 2010 21:14:49 -0400 (EDT) Received: from tranklukator.englab.brq.redhat.com ([10.34.26.254]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o621Embv025331; Thu, 1 Jul 2010 21:14:48 -0400 Received: by tranklukator.englab.brq.redhat.com (nbSMTP-1.00) for uid 500 onestero@redhat.com; Fri, 2 Jul 2010 03:13:04 +0200 (CEST) Date: Fri, 2 Jul 2010 03:13:02 +0200 From: Oleg Nesterov To: Tom Tromey , Roland McGrath , "Frank Ch. Eigler" Cc: archer@sourceware.org Subject: PATCH? gdb remote.c: readchar() should pop_target() if SERIAL_ERROR? Message-ID: <20100702011302.GA24599@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 Lines: 41 Xref: opsy mail.frysk:5116 MIME-Version: 1.0 Content-length: 1410 Hello. I was trying to learn how gdb works with gdbserver and hit the bug. The patch below seems to fix the problem for me but I am not sure it is correct, I never looked into the (complex!) gdb sources before. In short, sometimes gdb doing "target remote :tcp_port" refuses to exit, putpkt_binary() complains that putpkt failed and longjmp()s to the main loop. This happens sometimes if gdbserver dies. (gdb) q A debugging session is active. Inferior 1 [Remote target] will be killed. Quit anyway? (y or n) y putpkt: write failed: Broken pipe. (gdb) Not sure my analysis is correct, but I think that readchar() needs a fix. A read/recv from a socket doesn't necessarily returns EOF if the peer has closed the socket. It can return sock->sk_err set by the previous send if the peer dies and sets sk->sk_shutdown. The patch merely adds pop_target(). The more sophisticates fix should probably continue the reading, sock->sk_err was cleared and the socket may have the packets which we could read. Oleg. --- gdb-7.1/gdb/remote.c~ 2010-03-07 15:39:53.000000000 +0100 +++ gdb-7.1/gdb/remote.c 2010-07-02 02:38:09.000000000 +0200 @@ -6364,6 +6364,7 @@ readchar (int timeout) error (_("Remote connection closed")); /* no return */ case SERIAL_ERROR: + pop_target (); perror_with_name (_("Remote communication error")); /* no return */ case SERIAL_TIMEOUT: --=-=-=--