This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Catch exception in value_rtti_indirect_type

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

I tested the change on my machine, Ubuntu 14.10 x86-64.


	* valops.c (value_rtti_indirect_type): Catch exception thrown by

 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;
+        {
+	  target = value_ind (v);
+        }
+      if (except.error == MEMORY_ERROR)
+	  return NULL;
+      else if (except.error != GDB_NO_ERROR)
+	throw_exception (except);
+    }
     return NULL;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]