Message ID | 1411174953-8930-1-git-send-email-simon.marchi@ericsson.com |
---|---|
State | Superseded |
Headers |
Received: (qmail 16803 invoked by alias); 20 Sep 2014 01:02:51 -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-##L=##H@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 16790 invoked by uid 89); 20 Sep 2014 01:02:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=BAYES_00, SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: smtp.electronicbox.net Received: from smtp.electronicbox.net (HELO smtp.electronicbox.net) (96.127.255.82) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 20 Sep 2014 01:02:47 +0000 Received: from simark.localdomain (unknown [96.127.221.218]) by smtp.electronicbox.net (Postfix) with ESMTP id 54D0EDF38A; Fri, 19 Sep 2014 21:01:34 -0400 (EDT) From: Simon Marchi <simon.marchi@ericsson.com> To: gdb-patches@sourceware.org Cc: simon.marchi@polymtl.ca, Simon Marchi <simon.marchi@ericsson.com> Subject: [PATCH] Catch exception in value_rtti_indirect_type Date: Fri, 19 Sep 2014 21:02:33 -0400 Message-Id: <1411174953-8930-1-git-send-email-simon.marchi@ericsson.com> X-IsSubscribed: yes |
Commit Message
Simon Marchi
Sept. 20, 2014, 1:02 a.m. UTC
In the situation described in bug 17416 [1], 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 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. 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(-)
Comments
On 2014-09-19 09:02 PM, Simon Marchi wrote: > In the situation described in bug 17416 [1], 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 > 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. > > 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); > + } > else > return NULL; Ping
On 2014-10-20 01:50 PM, Simon Marchi wrote: > On 2014-09-19 09:02 PM, Simon Marchi wrote: >> In the situation described in bug 17416 [1], 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 >> 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. >> >> 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); >> + } >> else >> return NULL; > > Ping > Ping.
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
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); + } else return NULL;