public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug symtab/31697] heap-use-after-free in symtab
Date: Fri, 03 May 2024 12:49:47 +0000	[thread overview]
Message-ID: <bug-31697-4717-JruCui2jJS@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31697-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=31697

--- Comment #5 from Tom de Vries <vries at gcc dot gnu.org> ---
At first glance, seems to be an ordering problem.

tui_all_objfiles_removed should be executed after symtab_all_objfiles_removed.

This demonstrator patch fixes it by calling symtab_all_objfiles_removed at the
start of tui_all_objfiles_removed:
...
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 58648a8779d..f79c1641cab 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1726,9 +1726,11 @@ symtab_new_objfile_observer (struct objfile *objfile)
   symbol_cache_flush (objfile->pspace);
 }

+extern void symtab_all_objfiles_removed (program_space *pspace);
+
 /* This module's 'all_objfiles_removed' observer.  */

-static void
+void
 symtab_all_objfiles_removed (program_space *pspace)
 {
   symbol_cache_flush (pspace);
diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index cf48e709ed8..7baebb5e6a8 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -58,9 +58,14 @@ static void
 tui_new_objfile_hook (struct objfile* objfile)
 { tui_on_objfiles_changed (); }

+extern void symtab_all_objfiles_removed (program_space *pspace);
+
 static void
 tui_all_objfiles_removed (program_space *pspace)
-{ tui_on_objfiles_changed (); }
+{
+  symtab_all_objfiles_removed (pspace);
+  tui_on_objfiles_changed ();
+}

 /* Observer for the register_changed notification.  */

...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2024-05-03 12:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-03 11:43 [Bug symtab/31697] New: " ssbssa at sourceware dot org
2024-05-03 11:44 ` [Bug symtab/31697] " ssbssa at sourceware dot org
2024-05-03 11:46 ` ssbssa at sourceware dot org
2024-05-03 12:20 ` vries at gcc dot gnu.org
2024-05-03 12:31 ` vries at gcc dot gnu.org
2024-05-03 12:40 ` vries at gcc dot gnu.org
2024-05-03 12:49 ` vries at gcc dot gnu.org [this message]
2024-05-03 13:14 ` ssbssa at sourceware dot org
2024-05-04 12:11 ` ssbssa at sourceware dot org
2024-05-07 17:30 ` cvs-commit at gcc dot gnu.org
2024-05-07 17:32 ` ssbssa at sourceware dot org
2024-05-08 15:01 ` cvs-commit at gcc dot gnu.org

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=bug-31697-4717-JruCui2jJS@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@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).