From: Tom Tromey Date: Thu, 26 Jul 2018 23:54:00 +0000 (-0600) Subject: Clear static_links in reread_symbols X-Git-Tag: users/ARM/embedded-binutils-master-2018q4~406 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=22ad8107d35d833db000e5a5050c0f53af7af51f;p=thirdparty%2Fbinutils-gdb.git Clear static_links in reread_symbols -fsanitize=address pointed out a use-after free in objfile_register_static_link. The bug turned out to be that reread_symbols does not clear the static_links field; this leaves a hash table that is filled with freed pointers. Jan's (now quite old) idea of replacing reread_symbols with a simple delete/new still seems good to me, and it's worth noting that it would have avoided this bug. Tested by the buildbot and by observing the change with -fsanitize=address. gdb/ChangeLog 2018-10-19 Tom Tromey * symfile.c (reread_symbols): Clear "static_links". --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index da613eb769b..483b00e32a1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2018-10-19 Tom Tromey + + * symfile.c (reread_symbols): Clear "static_links". + 2018-10-19 Alan Hayward * aarch64-linux-tdep.c (AARCH64_SIGCONTEXT_RESERVED_SIZE): New diff --git a/gdb/symfile.c b/gdb/symfile.c index 6a1140edbcd..8ab6a25de7c 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2497,6 +2497,7 @@ reread_symbols (void) objfile->psymtabs_addrmap = NULL; objfile->free_psymtabs = NULL; objfile->template_symbols = NULL; + objfile->static_links = NULL; /* obstack_init also initializes the obstack so it is empty. We could use obstack_specify_allocation but