From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31068 invoked by alias); 27 Feb 2010 01:19:05 -0000 Received: (qmail 31052 invoked by uid 22791); 27 Feb 2010 01:19:04 -0000 X-SWARE-Spam-Status: No, hits=-7.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,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; Sat, 27 Feb 2010 01:18:59 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1R1IwaD031607 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 26 Feb 2010 20:18:58 -0500 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1R1ItIZ025563 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 26 Feb 2010 20:18:57 -0500 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id o1R1Ituh013385; Sat, 27 Feb 2010 02:18:55 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id o1R1ItJh013384; Sat, 27 Feb 2010 02:18:55 +0100 Date: Sat, 27 Feb 2010 01:19:00 -0000 From: Jan Kratochvil To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [patch] infcall: Remove gdb_assert ($sp underflow) Message-ID: <20100227011855.GA11090@host0.dyn.jankratochvil.net> References: <20100219224805.GA9681@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-08-17) 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: 2010-02/txt/msg00667.txt.bz2 On Fri, 26 Feb 2010 23:45:10 +0100, Tom Tromey wrote: > >>>>> "Jan" == Jan Kratochvil writes: > > Jan> set $sp=0 > Jan> call something() [...] > do people really do this sort of thing? Or is this a reduced case of some > other scenario that actually does happen? $sp=0 is a perfectly valid 16bit embedded device initialization with ROM 0..16KB and RAM 16KB..64KB address range with normal PUSH as *--$sp (and POP as *sp++). But it is true I have met this case as a consequence of a different problem. Assuming it is a bug in the ia64 part of the subsystem in Linux kernel for ptrace emulated on top of utrace (that is RHEL-5, such as RHEL-5.4). Reproducer instructions: http://cvs.fedoraproject.org/viewvc/rpms/gdb/F-12/gdb-ia64-infcall-workaround.patch?content-type=text%2Fplain&view=co FYI the ia64 kernel may lock up while dealing with this reproducer. After an inferior call and some commands inferior $sp gets read by ptrace as 0. The problem happens since arch-independent change: Re: [rfc, v3] Fix frame_id_inner comparison false positives http://sourceware.org/ml/gdb-patches/2008-08/msg00578.html http://sourceware.org/ml/gdb-cvs/2008-08/msg00182.html 916dde5d38b45a659514e47942ece70aec04cd78 specifically its last part: * stack.c (return_command): Directly pop the selected frame. which is at the bottom of this mail. I have not found there a bug in this GDB change. The problem is also not reproducible on ia64 RHEL-4 (RHEL-4.8) which uses non-utrace legacy ptrace implementation in its Linux kernel. Thanks, Jan --- src/gdb/stack.c 2008/08/21 18:14:39 1.176 +++ src/gdb/stack.c 2008/08/26 17:40:25 1.177 @@ -1844,29 +1844,8 @@ error (_("Not confirmed")); } - /* NOTE: cagney/2003-01-18: Is this silly? Rather than pop each - frame in turn, should this code just go straight to the relevant - frame and pop that? */ - - /* First discard all frames inner-to the selected frame (making the - selected frame current). */ - { - struct frame_id selected_id = get_frame_id (get_selected_frame (NULL)); - while (!frame_id_eq (selected_id, get_frame_id (get_current_frame ()))) - { - struct frame_info *frame = get_current_frame (); - if (frame_id_inner (get_frame_arch (frame), selected_id, - get_frame_id (frame))) - /* Caught in the safety net, oops! We've gone way past the - selected frame. */ - error (_("Problem while popping stack frames (corrupt stack?)")); - frame_pop (get_current_frame ()); - } - } - - /* Second discard the selected frame (which is now also the current - frame). */ - frame_pop (get_current_frame ()); + /* Discard the selected frame and all frames inner-to it. */ + frame_pop (get_selected_frame (NULL)); /* Store RETURN_VALUE in the just-returned register set. */ if (return_value != NULL)