From patchwork Fri Nov 14 00:39:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 3725 Received: (qmail 31419 invoked by alias); 14 Nov 2014 00:39:55 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 31309 invoked by uid 89); 14 Nov 2014 00:39:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ig0-f202.google.com Received: from mail-ig0-f202.google.com (HELO mail-ig0-f202.google.com) (209.85.213.202) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 14 Nov 2014 00:39:52 +0000 Received: by mail-ig0-f202.google.com with SMTP id r10so122451igi.3 for ; Thu, 13 Nov 2014 16:39:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:mime-version:content-type :content-transfer-encoding:message-id:date:to:cc:subject:in-reply-to :references; bh=YCEQxl0nuIvj3pE3x7UDBYhG0jZ0LLp1h5h+HCOD3bw=; b=F0XfpvQsTdGLYENLa6oXyD+cPyV59Mw/uVEHLcm173+eRU4m73QcGsRHLN6rHRs35V pun0moNs4eiOUxtDZl7MV9F9daFG4TTwUe2cdO8IcmVqqY51L9aFRXOdbORGQa7PmaMy Y6VHwev4xw9tn9ONK13ztZSP3K0Idp3FBsovREzrXtXoiR3ZTfkabjK6H7wl5uqSKo/v Bp47tu0e5H2T+QMogtjLbGVsoviBlhOJ12+olWVieccMQl1rHYaUZ5soi6vbZRx1cl1B GLJti4Fp2Hf14o+xlc4futJjRrZqCR7+u5OCj82QiCy09fZSq0gEbm63Jg980X0krvON fp9Q== X-Gm-Message-State: ALoCoQl3+dekwAsuFYmaQMTGrLtBww4yO+3BsWzG5avEcy4zgXyzrL7PqyMfyLiyA3HgRrXsbtTVFo553ci8uUrMHGTeEXPPfamPqc7QBebVMtnzUM7w8q0Bfm4bXKR1nE4/7UWiUIkneKOPH+B9+cElRx5wkXpMjyIEeBWuMfUwbPQFwsBUIQw= X-Received: by 10.182.33.134 with SMTP id r6mr45965228obi.34.1415925590719; Thu, 13 Nov 2014 16:39:50 -0800 (PST) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id s23si1135370yhf.0.2014.11.13.16.39.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Nov 2014 16:39:50 -0800 (PST) Received: from ruffy2.mtv.corp.google.com ([172.17.128.107]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id X4PEv4JI.1; Thu, 13 Nov 2014 16:39:50 -0800 From: Doug Evans MIME-Version: 1.0 Message-ID: <21605.20309.594319.769762@ruffy2.mtv.corp.google.com> Date: Thu, 13 Nov 2014 16:39:49 -0800 To: Daniel Colascione cc: gdb-patches Subject: [COMMITTED PATCH] Fix infinite loop in update_enumeration_type_from_children In-Reply-To: References: <543300A0.50705@dancol.org> <545FE524.5070607@dancol.org> X-IsSubscribed: yes Doug Evans writes: > On Sun, Nov 9, 2014 at 2:05 PM, Daniel Colascione wrote: > > On 10/08/2014 06:58 AM, Doug Evans wrote: > >> Changing the loop to a for loop is another way to go, and arguably preferable. > > > > Either way, it looks like this bug is unfixed in master. Now that I have > > papers, can this patch (or an equivalent for-loop version) be committed? > > Hi. > I kinda like the for-loop version better. > I'll get that checked in today. Committed. 2014-11-13 Doug Evans * dwarf2read.c (update_enumeration_type_from_children): Avoid infinite loop. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index ce37adf..1250bc7 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -13231,7 +13231,7 @@ update_enumeration_type_from_children (struct die_info *die, struct dwarf2_cu *cu) { struct obstack obstack; - struct die_info *child_die = die->child; + struct die_info *child_die; int unsigned_enum = 1; int flag_enum = 1; ULONGEST mask = 0; @@ -13240,13 +13240,16 @@ update_enumeration_type_from_children (struct die_info *die, obstack_init (&obstack); old_chain = make_cleanup_obstack_free (&obstack); - while (child_die != NULL && child_die->tag) + for (child_die = die->child; + child_die != NULL && child_die->tag; + child_die = sibling_die (child_die)) { struct attribute *attr; LONGEST value; const gdb_byte *bytes; struct dwarf2_locexpr_baton *baton; const char *name; + if (child_die->tag != DW_TAG_enumerator) continue; @@ -13274,7 +13277,6 @@ update_enumeration_type_from_children (struct die_info *die, a flag type, no need to look at the rest of the enumerates. */ if (!unsigned_enum && !flag_enum) break; - child_die = sibling_die (child_die); } if (unsigned_enum)