From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3934 invoked by alias); 19 Feb 2010 22:48:14 -0000 Received: (qmail 3926 invoked by uid 22791); 19 Feb 2010 22:48:13 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_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; Fri, 19 Feb 2010 22:48:09 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1JMm8dE004884 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 19 Feb 2010 17:48:08 -0500 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1JMm65p018882 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 19 Feb 2010 17:48:07 -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 o1JMm5ZX009716 for ; Fri, 19 Feb 2010 23:48:05 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id o1JMm5oQ009715 for gdb-patches@sourceware.org; Fri, 19 Feb 2010 23:48:05 +0100 Date: Fri, 19 Feb 2010 22:48:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] infcall: Remove gdb_assert ($sp overflow) Message-ID: <20100219224805.GA9681@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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/msg00515.txt.bz2 Hi, set $sp=0 call something() -> ../../gdb/infcall.c:521: internal-error: call_function_by_hand: Assertion `(gdbarch_inner_than (gdbarch, 1, 2) && sp <= old_sp) || (gdbarch_inner_than (gdbarch, 2, 1) && sp >= old_sp)' failed. as $sp - frame == 0xffffsmth which is not lower than $sp. It must not be gdb_assert(). It can be an error() but I left it just to do: (gdb) set $sp=0 (gdb) call doubleit (1) Cannot access memory at address 0xffffffffffffff78 (gdb) set $sp=-1 (gdb) call doubleit (1) Cannot access memory at address 0xffffffffffffff68 Unaware how inconvenient is an intentional crash of the testcase on some embedded/non-MMU systems. No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu. Thanks, Jan gdb/ 2010-02-19 Jan Kratochvil * infcall.c (call_function_by_hand): Remove gdb_assert on sp and old_sp. New comment. gdb/testsuite/ 2010-02-19 Jan Kratochvil * gdb.base/callfuncs.exp: New tests for $spval 0 and -1. Remove return. --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -518,10 +518,9 @@ call_function_by_hand (struct value *function, int nargs, struct value **args) /* Stack grows up. */ sp = gdbarch_frame_align (gdbarch, old_sp + 1); } - gdb_assert ((gdbarch_inner_than (gdbarch, 1, 2) - && sp <= old_sp) - || (gdbarch_inner_than (gdbarch, 2, 1) - && sp >= old_sp)); + /* SP may have overflown address zero here from OLD_SP. Memory access + functions will probably fail in such case but that is a target's + problem. */ } else /* FIXME: cagney/2002-09-18: Hey, you loose! --- a/gdb/testsuite/gdb.base/callfuncs.exp +++ b/gdb/testsuite/gdb.base/callfuncs.exp @@ -469,5 +469,18 @@ if {$old_reg_content == $new_reg_content} then { fail "nested call dummies preserve register contents" } -return 0 +# GDB should not crash by internal error on $sp overflow during the inferior +# call. It is OK it will stop on some: Cannot access memory at address 0x$hex. +foreach spval {0 -1} { + set old_ldprefix $pf_prefix + lappend pf_prefix "sp=$spval:" + + gdb_test {set $old_sp = $sp} + gdb_test "set \$sp = $spval" + + gdb_test "call doubleit (1)" + + gdb_test {set $sp = $old_sp} + set pf_prefix $old_ldprefix +}