public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Avoid infinite recursion in get_msymbol_address
Date: Fri, 10 Apr 2020 13:22:25 +0000 (GMT)	[thread overview]
Message-ID: <20200410132225.770D6385DC03@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0c4311ab90e46d2ae0cc29160641b92220d10299

commit 0c4311ab90e46d2ae0cc29160641b92220d10299
Author: Tom Tromey <tromey@adacore.com>
Date:   Fri Apr 10 07:18:49 2020 -0600

    Avoid infinite recursion in get_msymbol_address
    
    Sometimes, get_msymbol_address can cause infinite recursion, leading
    to a crash.  This was reported previously here:
    
    https://sourceware.org/pipermail/gdb-patches/2019-November/162154.html
    
    A user on irc reported this as well, and with his help and the help of
    a friend of his, we found that the problem occurred because, when
    reloading a separate debug objfile, the objfile would lose the
    OBJF_MAINLINE flag.  This would cause some symbols from this separate
    debug objfile to be marked "maybe_copied" -- but then
    get_msymbol_address could find the same symbol and fail as reported.
    
    This patch fixes the bug by preserving OBJF_MAINLINE.
    
    No test case, unfortunately, because I could not successfully make
    one.
    
    gdb/ChangeLog
    2020-04-10  Tom Tromey  <tromey@adacore.com>
    
            * symfile.c (symbol_file_add_separate): Preserve OBJF_MAINLINE.

Diff:
---
 gdb/ChangeLog | 4 ++++
 gdb/symfile.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index fa05f93a5e5..661a41467bb 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2020-04-10  Tom Tromey  <tromey@adacore.com>
+
+	* symfile.c (symbol_file_add_separate): Preserve OBJF_MAINLINE.
+
 2020-04-10  Tom Tromey  <tromey@adacore.com>
 
 	* symtab.c (get_symbol_address, get_msymbol_address): Skip
diff --git a/gdb/symfile.c b/gdb/symfile.c
index bd27a1fefef..61053298a89 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1163,7 +1163,7 @@ symbol_file_add_separate (bfd *bfd, const char *name,
   symbol_file_add_with_addrs
     (bfd, name, symfile_flags, &sap,
      objfile->flags & (OBJF_REORDERED | OBJF_SHARED | OBJF_READNOW
-		       | OBJF_USERLOADED),
+		       | OBJF_USERLOADED | OBJF_MAINLINE),
      objfile);
 }


                 reply	other threads:[~2020-04-10 13:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200410132225.770D6385DC03@sourceware.org \
    --to=tromey@sourceware.org \
    --cc=gdb-cvs@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).