This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RFC: fix PR 14634
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 27 Sep 2012 14:15:21 -0600
- Subject: RFC: fix PR 14634
This fixes PR python/14634.
There is a bug in the gdb.Symbol destructor that will cause a crash if
an objfile-less Symbol is destroyed.
The fix is to simply check for NULL here.
Built and regtested on x86-64 Fedora 16.
New test case included.
Tom
PR python/14634:
* python/py-symbol.c (sympy_dealloc): Check for NULL symbol.
* gdb.python/py-symbol.exp: Test symbol destructor.
---
gdb/python/py-symbol.c | 2 +-
gdb/testsuite/gdb.python/py-symbol.exp | 1 +
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 00a8477..83d272e 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -335,7 +335,7 @@ sympy_dealloc (PyObject *obj)
if (sym_obj->prev)
sym_obj->prev->next = sym_obj->next;
- else if (SYMBOL_SYMTAB (sym_obj->symbol))
+ else if (sym_obj->symbol && SYMBOL_SYMTAB (sym_obj->symbol))
{
set_objfile_data (SYMBOL_SYMTAB (sym_obj->symbol)->objfile,
sympy_objfile_data_key, sym_obj->next);
diff --git a/gdb/testsuite/gdb.python/py-symbol.exp b/gdb/testsuite/gdb.python/py-symbol.exp
index bc20ee4..4442e79 100644
--- a/gdb/testsuite/gdb.python/py-symbol.exp
+++ b/gdb/testsuite/gdb.python/py-symbol.exp
@@ -160,3 +160,4 @@ gdb_test "python print a\[0\].is_valid()" "True" "Test symbol validity"
delete_breakpoints
gdb_unload
gdb_test "python print a\[0\].is_valid()" "False" "Test symbol validity"
+gdb_test_no_output "python a = None" "Test symbol destructor"
--
1.7.7.6