From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10124 invoked by alias); 4 Dec 2014 17:47:55 -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 10111 invoked by uid 89); 4 Dec 2014 17:47:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 04 Dec 2014 17:47:50 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sB4Hlcvs029388 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 4 Dec 2014 12:47:38 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sB4HlaVL002628; Thu, 4 Dec 2014 12:47:37 -0500 Message-ID: <54809E38.3080606@redhat.com> Date: Thu, 04 Dec 2014 17:47:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Simon Marchi , gdb-patches@sourceware.org CC: simon.marchi@polymtl.ca Subject: Re: [PATCH] Catch exception in value_rtti_indirect_type References: <1411174953-8930-1-git-send-email-simon.marchi@ericsson.com> In-Reply-To: <1411174953-8930-1-git-send-email-simon.marchi@ericsson.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-12/txt/msg00106.txt.bz2 On 09/20/2014 02:02 AM, Simon Marchi wrote: > In the situation described in bug 17416 [1], Could you paste that in the commit log please? > an exception thrown in > value_ind can propagate too far and leave an half-built variable object, > leading to a wrong state. This patch adds a TRY_CATCH to catch it and > makes value_rtti_indirect_type return NULL in that case, meaning > that the type of the pointed object could not be found. > > If you want, I can also integrate the test case provided in the bug Yes please. > description. I just don't know how to name it without giving it a > ridiculously long name such as > mi-var-list-children-with-print-object-on-and-a-null-pointer-to-a-structure-that-contains-a-pointer-to-a-structure.exp. Perhaps mi-var-list-children-invalid-grandchild.exp. > > I tested the change on my machine, Ubuntu 14.10 x86-64. > > gdb/Changelog: > > * valops.c (value_rtti_indirect_type): Catch exception thrown by > value_ind. > > [1] https://sourceware.org/bugzilla/show_bug.cgi?id=17416 > --- > gdb/valops.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/gdb/valops.c b/gdb/valops.c > index e1decf0..c1a0c86 100644 > --- a/gdb/valops.c > +++ b/gdb/valops.c > @@ -3609,7 +3609,18 @@ value_rtti_indirect_type (struct value *v, int *full, > if (TYPE_CODE (type) == TYPE_CODE_REF) > target = coerce_ref (v); > else if (TYPE_CODE (type) == TYPE_CODE_PTR) > - target = value_ind (v); > + { > + volatile struct gdb_exception except; > + > + TRY_CATCH (except, RETURN_MASK_ERROR) > + { > + target = value_ind (v); > + } > + if (except.error == MEMORY_ERROR) > + return NULL; > + else if (except.error != GDB_NO_ERROR) > + throw_exception (except); Indentation looks odd. But, could you write it like this instead ? volatile struct gdb_exception except; TRY_CATCH (except, RETURN_MASK_ERROR) { target = value_ind (v); } if (except.reason < 0) { if (except.error == MEMORY_ERROR) { /* Add comment here. */ return NULL; } throw_exception (except); } Thanks, Pedro Alves