public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH] Clear static_links in reread_symbols
Date: Thu, 18 Oct 2018 22:07:00 -0000	[thread overview]
Message-ID: <20181018220522.28062-1-tom@tromey.com> (raw)

-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

             reply	other threads:[~2018-10-18 22:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-18 22:07 Tom Tromey [this message]
2018-10-19 11:28 ` Kevin Buettner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181018220522.28062-1-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).