aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp12
-rw-r--r--gdb/varobj.c6
2 files changed, 16 insertions, 2 deletions
diff --git a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp
index 2688851..4328c59 100644
--- a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp
+++ b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp
@@ -85,3 +85,15 @@ mi_gdb_test "-var-list-children c1.car.atom" \
mi_gdb_test "-var-info-path-expression c1.car.atom.ival" \
"\\^error,msg=\".*\"" \
"-var-info-path-expression c1.car.atom.ival"
+
+
+# Regression test for a crasher that would occur when deleting a
+# varobj that held an iterator that hadn't yet been completed.
+# See PR varobj/28131.
+mi_gdb_test "-var-create c1_again * &c1" \
+ "\\^done.*" \
+ "-var-create c1_again * &c1"
+mi_gdb_test "-var-list-children c1_again 0 1" \
+ "\\^done,numchild=\"1\",children=.child=\{name=\"c1_again.car\".*" \
+ "-var-list-children c1_again"
+mi_delete_varobj c1_again "delete c1_again"
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 7928d90..d0c857a 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -1844,10 +1844,12 @@ varobj::~varobj ()
}
#endif
+ /* This must be deleted before the root object, because Python-based
+ destructors need access to some components. */
+ delete var->dynamic;
+
if (is_root_p (var))
delete var->root;
-
- delete var->dynamic;
}
/* Return the type of the value that's stored in VAR,