From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5446 invoked by alias); 20 Nov 2013 21:21:40 -0000 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 Received: (qmail 5430 invoked by uid 89); 20 Nov 2013 21:21:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_20,RDNS_NONE,SPF_HELO_PASS,SPF_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Nov 2013 21:21:38 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAKLLT6g015136 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 20 Nov 2013 16:21:30 -0500 Received: from barimba (ovpn-113-124.phx2.redhat.com [10.3.113.124]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rAKLLSFA002933 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 20 Nov 2013 16:21:28 -0500 From: Tom Tromey To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Don't let two frames with the same id end up in the frame chain. (Re: [PATCH 1/2] avoid infinite loop with bad debuginfo) References: <1384375873-32160-1-git-send-email-tromey@redhat.com> <1384375873-32160-2-git-send-email-tromey@redhat.com> <52850730.1060109@redhat.com> <87d2lxpo1l.fsf@fleche.redhat.com> <528B7F15.7040605@redhat.com> <87vbzomm78.fsf@fleche.redhat.com> <528B8FF6.7000406@redhat.com> <87siusl10r.fsf@fleche.redhat.com> <528BB700.4000802@redhat.com> <87fvqskumd.fsf@fleche.redhat.com> <528CFEDE.1040505@redhat.com> Date: Thu, 21 Nov 2013 00:33:00 -0000 In-Reply-To: <528CFEDE.1040505@redhat.com> (Pedro Alves's message of "Wed, 20 Nov 2013 18:26:38 +0000") Message-ID: <871u2aixbc.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2013-11/txt/msg00610.txt.bz2 >>>>> "Pedro" == Pedro Alves writes: Tom> Really not looking forward to writing the test. Pedro> Yeah, me neither. :-P Well, I took at stab at it today, and totally failed. I will try to catch you on irc tomorrow to pick your brain, if that's ok with you, to try to understand how I could get a test case. Pedro> Subject: Don't let two frames with the same id end up in the frame chain. Pedro> The UNWIND_SAME_ID check is done between THIS_FRAME and the next Pedro> frame. But at this point, it's already too late -- we ended up with Pedro> two frames with the same ID in the frame chain. Each frame having its Pedro> own ID is an invariant assumed throughout GDB. So this patch applies Pedro> the UNWIND_SAME_ID detection earlier, right after the previous frame Pedro> is unwond, discarding the dup frame if a cycle is detected. s/unwond/unwound/ FWIW I have nearly the identical patch here :) I think it's a good idea. I also have the appended, which makes the frame stash behave a little nicer if an unwinder gives a duplicate frame id. Probably not needed in addition to the patch you sent, but on the other hand, cheap. Tom diff --git a/gdb/frame.c b/gdb/frame.c index 63f20d5..dd419c9 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -203,7 +203,13 @@ frame_stash_add (struct frame_info *frame) slot = (struct frame_info **) htab_find_slot (frame_stash, frame, INSERT); - *slot = frame; + + /* While it is invalid for two frames to have the same ID, it + may happen due to a bug elsewhere in gdb. And, should this + happen, it is better for the frame stash to return the newer + frame. So, ignore duplicates here. */ + if (*slot == NULL) + *slot = frame; } }