From: Mark Kettenis <kettenis@chello.nl>
To: gdb-patches@sources.redhat.com
Cc: Peter.Schauer@regent.e-technik.tu-muenchen.de
Subject: [PATCH] Clear per-objfile data upon rereading a symbol file
Date: Sun, 26 Oct 2003 21:12:00 -0000 [thread overview]
Message-ID: <200310262110.h9QLAgta000512@elgar.kettenis.dyndns.org> (raw)
Peter Schrauer pointed out to me that upon re-reading a symbolf file,
we don't clear the per-objfile data pointers, whereas we clear almost
everything else in the symbol file related `struct objfile'. This
currently leaves us with dangling pointers into freed obstacks. The
attached patch fixes this.
I'll check this in on both branches in a few days unless somebody
objects, since this fixes a bug where GDB crashes. We can't have that
:-(.
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* objfiles.h (clear_objfile_data): New prototype.
* objfiles.c (clear_objfile_data): New function.
* symfile.c (reread_symbols): Clear per-objfile data.
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.109
diff -u -p -r1.109 symfile.c
--- symfile.c 21 Sep 2003 01:26:45 -0000 1.109
+++ symfile.c 26 Oct 2003 21:05:52 -0000
@@ -1969,6 +1969,7 @@ reread_symbols (void)
memset (&objfile->msymbol_demangled_hash, 0,
sizeof (objfile->msymbol_demangled_hash));
objfile->fundamental_types = NULL;
+ clear_objfile_data (objfile);
if (objfile->sf != NULL)
{
(*objfile->sf->sym_finish) (objfile);
Index: objfiles.c
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.c,v
retrieving revision 1.38
diff -u -p -r1.38 objfiles.c
--- objfiles.c 20 Oct 2003 14:38:42 -0000 1.38
+++ objfiles.c 26 Oct 2003 21:05:55 -0000
@@ -1166,6 +1166,13 @@ objfile_free_data (struct objfile *objfi
}
void
+clear_objfile_data (struct objfile *objfile)
+{
+ gdb_assert (objfile->data != NULL);
+ memset (objfile->data, 0, objfile->num_data * sizeof (void *));
+}
+
+void
set_objfile_data (struct objfile *objfile, const struct objfile_data *data,
void *value)
{
Index: objfiles.h
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.h,v
retrieving revision 1.26
diff -u -p -r1.26 objfiles.h
--- objfiles.h 14 Sep 2003 02:04:44 -0000 1.26
+++ objfiles.h 26 Oct 2003 21:06:00 -0000
@@ -599,6 +599,7 @@ extern int is_in_import_list (char *, st
modules. */
extern const struct objfile_data *register_objfile_data (void);
+extern void clear_objfile_data (struct objfile *objfile);
extern void set_objfile_data (struct objfile *objfile,
const struct objfile_data *data, void *value);
extern void *objfile_data (struct objfile *objfile,
next reply other threads:[~2003-10-26 21:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-26 21:12 Mark Kettenis [this message]
2003-10-27 16:14 ` Andrew Cagney
2003-10-27 20:57 ` Mark Kettenis
2003-10-28 16:05 ` Elena Zannoni
2003-10-29 18:43 ` Mark Kettenis
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=200310262110.h9QLAgta000512@elgar.kettenis.dyndns.org \
--to=kettenis@chello.nl \
--cc=Peter.Schauer@regent.e-technik.tu-muenchen.de \
--cc=gdb-patches@sources.redhat.com \
/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