aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2013-06-18 23:35:24 +0000
committerJoel Brobecker <brobecker@gnat.com>2013-06-18 23:35:24 +0000
commit59b0c7c17a406c7448d9fc362f886ee338254655 (patch)
tree3d963ed1927482c47ad9926514ecded02cae257d
parent427cd150eed8c0dd4f0d0a1105448b4ebe36da6d (diff)
downloadgdb-59b0c7c17a406c7448d9fc362f886ee338254655.zip
gdb-59b0c7c17a406c7448d9fc362f886ee338254655.tar.gz
gdb-59b0c7c17a406c7448d9fc362f886ee338254655.tar.bz2
do not use dwarf2_per_objfile in dwarf2_per_objfile_free.
This patch fixes a case of multiple calls freeing the same data while free-ing objfiles that have child objfiles (separate debug info, as is the case on Darwin targets). Following the code, free_objfile_separate_debug iterates over all child objfiles of the parent objfile, calling free_objfile: for (child = objfile->separate_debug_objfile; child;) { struct objfile *next_child = child->separate_debug_objfile_link; free_objfile (child); child = next_child; } This causes, among other things, the free'ing of the child objfile's private data: /* Discard any data modules have associated with the objfile. The function still may reference objfile->obfd. */ objfile_free_data (objfile); This indirectly calls(back) dwarf2_per_objfile_free, which tries to free the dwarf2read-specific data by using the dwarf2_per_objfile global, eg: for (ix = 0; ix < dwarf2_per_objfile->n_comp_units; ++ix) Even if we were lucky enough the first time around that this global actually corresponds to the objfile being destroyed, the global will still have the same value at the second iteration, and thus become dangling. Indeed, after dwarf2_per_objfile_free returns eventually back to free_objfile, free_objfile then deallocates its objfile_obstack, where the dwarf2_per_objfile is allocated. Ironically, there should be no need to access that global at all, here, since the data is passed as an argument of the callback. And it looks like the dwo/dwp/[...]-handling code is in fact already using that argument, rather than the global. This patch thus fixes the problem by doing the same, replacing all references to DWARF2_PER_OBJFILE by uses of DATA instead. gdb/ChangeLog: * dwarf2read.c (dwarf2_per_objfile): Replace uses of DWARF2_PER_OBJFILE by uses of DATA instead.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/dwarf2read.c11
2 files changed, 10 insertions, 6 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d658bfb..edfeec9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2013-06-18 Joel Brobecker <brobecker@adacore.com>
+
+ * dwarf2read.c (dwarf2_per_objfile): Replace uses of
+ DWARF2_PER_OBJFILE by uses of DATA instead.
+
2013-06-18 Tom Tromey <tromey@redhat.com>
* break-catch-sig.c (signal_catchpoint_explains_signal): Add 'sig'
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 316bb86..0cb9568 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -20491,14 +20491,13 @@ dwarf2_per_objfile_free (struct objfile *objfile, void *d)
struct dwarf2_per_objfile *data = d;
int ix;
- for (ix = 0; ix < dwarf2_per_objfile->n_comp_units; ++ix)
- VEC_free (dwarf2_per_cu_ptr,
- dwarf2_per_objfile->all_comp_units[ix]->imported_symtabs);
+ for (ix = 0; ix < data->n_comp_units; ++ix)
+ VEC_free (dwarf2_per_cu_ptr, data->all_comp_units[ix]->imported_symtabs);
- for (ix = 0; ix < dwarf2_per_objfile->n_type_units; ++ix)
+ for (ix = 0; ix < data->n_type_units; ++ix)
VEC_free (dwarf2_per_cu_ptr,
- dwarf2_per_objfile->all_type_units[ix]->per_cu.imported_symtabs);
- xfree (dwarf2_per_objfile->all_type_units);
+ data->all_type_units[ix]->per_cu.imported_symtabs);
+ xfree (data->all_type_units);
VEC_free (dwarf2_section_info_def, data->types);