Message ID | 533EC64E.1010302@broadcom.com |
---|---|
State | Superseded |
Headers |
Return-Path: <x14314964@homiemail-mx23.g.dreamhost.com> X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx23.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 5221436007F for <siddhesh@wilcox.dreamhost.com>; Fri, 4 Apr 2014 07:48:52 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14314964) id F41A5624D9D2A; Fri, 4 Apr 2014 07:48:51 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx23.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx23.g.dreamhost.com (Postfix) with ESMTPS id CC5646249B8B4 for <gdb@patchwork.siddhesh.in>; Fri, 4 Apr 2014 07:48:51 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; q=dns; s=default; b=uoPaO+a5wMZ2mHiWRsN8R2SAph5j41q6dFN0n4dgXlb Sc+J2s3HG5R/HvzntIAnLeFmNBti5RjuuaJ64ilfQTvHNhWEbanCp+W9MAeJVg0V C1DZ8dMmhpAlkeUYrIX6VPDhN63WmYYPouyPQr3jWqUwMHjlYN0GG2nGF+178Edw = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; s=default; bh=CoQ63yvZ5kpDxuYVpJU+F0uCEdA=; b=CAm5DQyKCw1xMC1d1 G8Wd0Cyp3ADwRC1ESzLMVLzkuhL5AWNMcgL1VNI5PDmmNimKZlck7ABs4782kQeP dT5MijWAR0hbFloKhxdsAQFCNFMAf8ftp4cDEh7MeuveLTeec5k2GcRRKNt8agYx J2r5KepAY9abe03mDw0Gy7cP3E= Received: (qmail 14581 invoked by alias); 4 Apr 2014 14:48:50 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-gdb=patchwork.siddhesh.in@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 14571 invoked by uid 89); 4 Apr 2014 14:48:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-gw3-out.broadcom.com Received: from mail-gw3-out.broadcom.com (HELO mail-gw3-out.broadcom.com) (216.31.210.64) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 04 Apr 2014 14:48:49 +0000 Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw3-out.broadcom.com with ESMTP; 04 Apr 2014 08:05:23 -0700 Received: from IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.174.1; Fri, 4 Apr 2014 07:48:47 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) with Microsoft SMTP Server id 14.3.174.1; Fri, 4 Apr 2014 07:48:47 -0700 Received: from [10.177.73.80] (unknown [10.177.73.80]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 3CFCEEAD4B for <gdb-patches@sourceware.org>; Fri, 4 Apr 2014 07:48:47 -0700 (PDT) Message-ID: <533EC64E.1010302@broadcom.com> Date: Fri, 4 Apr 2014 15:48:46 +0100 From: Andrew Burgess <aburgess@broadcom.com> User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: <gdb-patches@sourceware.org> Subject: [RFC 2/4] Remove previous frame if we error during compute_frame_id References: <533EC5B7.6080600@broadcom.com> In-Reply-To: <533EC5B7.6080600@broadcom.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in |
Commit Message
Andrew Burgess
April 4, 2014, 2:48 p.m. UTC
In get_prev_frame_if_no_cycle, if we throw an error during compute_frame_id then we are left in a state where THIS_FRAME has a PREV_FRAME attached, but PREV_FRAME has no frame id. This is an unexpected state that causes internal errors and assertions to fire. This patch adds a cleanup that removes the previous frame created by get_prev_frame_raw if we get an error. OK to apply? Thanks, Andrew gdb/ChangeLog: * frame.c (remove_prev_frame): New function. (get_prev_frame_if_no_cycle): Create / discard cleanup using remove_prev_frame. most likely a stack cycle, so we discard it, and mark THIS_FRAME as @@ -1745,28 +1761,36 @@ static struct frame_info * get_prev_frame_if_no_cycle (struct frame_info *this_frame) { struct frame_info *prev_frame; + struct cleanup *prev_frame_cleanup; prev_frame = get_prev_frame_raw (this_frame); if (prev_frame == NULL) return NULL; - compute_frame_id (prev_frame); - if (frame_stash_add (prev_frame)) - return prev_frame; + /* The cleanup will remove the previous frame that get_prev_frame_raw + linked onto THIS_FRAME. */ + prev_frame_cleanup = make_cleanup (remove_prev_frame, this_frame); - /* Another frame with the same id was already in the stash. We just - detected a cycle. */ - if (frame_debug) + compute_frame_id (prev_frame); + if (!frame_stash_add (prev_frame)) { - fprintf_unfiltered (gdb_stdlog, "-> "); - fprint_frame (gdb_stdlog, NULL); - fprintf_unfiltered (gdb_stdlog, " // this frame has same ID }\n"); + /* Another frame with the same id was already in the stash. We just + detected a cycle. */ + if (frame_debug) + { + fprintf_unfiltered (gdb_stdlog, "-> "); + fprint_frame (gdb_stdlog, NULL); + fprintf_unfiltered (gdb_stdlog, " // this frame has same ID }\n"); + } + this_frame->stop_reason = UNWIND_SAME_ID; + /* Unlink. */ + prev_frame->next = NULL; + this_frame->prev = NULL; + prev_frame = NULL; } - this_frame->stop_reason = UNWIND_SAME_ID; - /* Unlink. */ - prev_frame->next = NULL; - this_frame->prev = NULL; - return NULL; + + discard_cleanups (prev_frame_cleanup); + return prev_frame; } /* Return a "struct frame_info" corresponding to the frame that called
diff --git a/gdb/frame.c b/gdb/frame.c index 97d54e9..5f05968 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1733,6 +1733,22 @@ frame_register_unwind_location (struct frame_info *this_frame, int regnum, } } +/* Called during frame unwinding to remove a previous frame pointer from a + frame passed in ARG. */ + +static void +remove_prev_frame (void *arg) +{ + struct frame_info *this_frame, *prev_frame; + + this_frame = (struct frame_info *) arg; + prev_frame = this_frame->prev; + gdb_assert (prev_frame != NULL); + + prev_frame->next = NULL; + this_frame->prev = NULL; +} + /* Get the previous raw frame, and check that it is not identical to same other frame frame already in the chain. If it is, there is