Use gdb_bfd_ref_ptr in objfile
This changes struct objfile to use a gdb_bfd_ref_ptr. In addition to removing some manual memory management, this fixes a use-after-free that was introduced by the registry rewrite series. The issue there was that, in some cases, registry shutdown could refer to memory that had already been freed. This help fix the bug by delaying the destruction of the BFD reference (and thus the per-bfd object) until after the registry has been shut down.
This commit is contained in:
parent
4d44946794
commit
98badbfdc2
40 changed files with 256 additions and 241 deletions
|
@ -157,7 +157,7 @@ objfpy_get_build_id (PyObject *self, void *closure)
|
|||
|
||||
try
|
||||
{
|
||||
build_id = build_id_bfd_get (objfile->obfd);
|
||||
build_id = build_id_bfd_get (objfile->obfd.get ());
|
||||
}
|
||||
catch (const gdb_exception &except)
|
||||
{
|
||||
|
@ -448,7 +448,7 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
|
|||
{
|
||||
gdb_bfd_ref_ptr abfd (symfile_bfd_open (file_name));
|
||||
|
||||
symbol_file_add_separate (abfd.get (), file_name, 0, obj->objfile);
|
||||
symbol_file_add_separate (abfd, file_name, 0, obj->objfile);
|
||||
}
|
||||
catch (const gdb_exception &except)
|
||||
{
|
||||
|
@ -625,7 +625,7 @@ objfpy_lookup_objfile_by_build_id (const char *build_id)
|
|||
/* Don't return separate debug files. */
|
||||
if (objfile->separate_debug_objfile_backlink != NULL)
|
||||
continue;
|
||||
obfd_build_id = build_id_bfd_get (objfile->obfd);
|
||||
obfd_build_id = build_id_bfd_get (objfile->obfd.get ());
|
||||
if (obfd_build_id == NULL)
|
||||
continue;
|
||||
if (objfpy_build_id_matches (obfd_build_id, build_id))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue