From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10067 invoked by alias); 26 Oct 2003 21:12:04 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 9968 invoked from network); 26 Oct 2003 21:12:00 -0000 Received: from unknown (HELO walton.kettenis.dyndns.org) (213.93.115.144) by sources.redhat.com with SMTP; 26 Oct 2003 21:12:00 -0000 Received: from elgar.kettenis.dyndns.org (elgar.kettenis.dyndns.org [192.168.0.2]) by walton.kettenis.dyndns.org (8.12.6p3/8.12.6) with ESMTP id h9QLAguA000469; Sun, 26 Oct 2003 22:10:42 +0100 (CET) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: from elgar.kettenis.dyndns.org (localhost [127.0.0.1]) by elgar.kettenis.dyndns.org (8.12.6p3/8.12.6) with ESMTP id h9QLAgFB000515; Sun, 26 Oct 2003 22:10:42 +0100 (CET) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: (from kettenis@localhost) by elgar.kettenis.dyndns.org (8.12.6p3/8.12.6/Submit) id h9QLAgta000512; Sun, 26 Oct 2003 22:10:42 +0100 (CET) Date: Sun, 26 Oct 2003 21:12:00 -0000 Message-Id: <200310262110.h9QLAgta000512@elgar.kettenis.dyndns.org> From: Mark Kettenis 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 X-SW-Source: 2003-10/txt/msg00773.txt.bz2 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 * 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,