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: Sat, 20 Sep 2014 01:02:00 -0000 [thread overview]
Message-ID: <1411174953-8930-1-git-send-email-simon.marchi@ericsson.com> (raw)
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;
--
2.1.0
next reply other threads:[~2014-09-20 1:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-20 1:02 Simon Marchi [this message]
2014-10-20 17:50 ` Simon Marchi
2014-12-01 13:35 ` Simon Marchi
2014-12-04 17:47 ` Pedro Alves
2014-12-05 20:32 ` [PATCH v2] " Simon Marchi
2015-01-23 0:13 ` Simon Marchi
2015-01-23 14:35 ` Pedro Alves
2015-01-23 16:35 ` Simon Marchi
2015-01-23 18:00 ` Pedro Alves
2015-01-24 1:46 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1411174953-8930-1-git-send-email-simon.marchi@ericsson.com \
--to=simon.marchi@ericsson.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).