* [PATCH] Clear static_links in reread_symbols
@ 2018-10-18 22:07 Tom Tromey
2018-10-19 11:28 ` Kevin Buettner
0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2018-10-18 22:07 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
-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-18 Tom Tromey <tom@tromey.com>
* symfile.c (reread_symbols): Clear "static_links".
---
gdb/ChangeLog | 4 ++++
gdb/symfile.c | 1 +
2 files changed, 5 insertions(+)
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 6a1140edbc..8ab6a25de7 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
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Clear static_links in reread_symbols
2018-10-18 22:07 [PATCH] Clear static_links in reread_symbols Tom Tromey
@ 2018-10-19 11:28 ` Kevin Buettner
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Buettner @ 2018-10-19 11:28 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
On Thu, 18 Oct 2018 16:05:22 -0600
Tom Tromey <tom@tromey.com> wrote:
> Tested by the buildbot and by observing the change with
> -fsanitize=address.
>
> gdb/ChangeLog
> 2018-10-18 Tom Tromey <tom@tromey.com>
>
> * symfile.c (reread_symbols): Clear "static_links".
Okay.
Kevin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-10-19 11:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-18 22:07 [PATCH] Clear static_links in reread_symbols Tom Tromey
2018-10-19 11:28 ` Kevin Buettner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).