]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Avoid infinite recursion in get_msymbol_address
authorTom Tromey <tromey@adacore.com>
Fri, 10 Apr 2020 13:18:49 +0000 (07:18 -0600)
committerJoel Brobecker <brobecker@adacore.com>
Sun, 17 May 2020 15:55:18 +0000 (08:55 -0700)
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.

(cherry picked from commit 0c4311ab90e46d2ae0cc29160641b92220d10299)

gdb/ChangeLog
gdb/symfile.c

index d67864511bad9fb5d9f9cadcefff40681909b919..accbb8bd851fa1a042352ac62356c2ff426cdc4f 100644 (file)
@@ -1,3 +1,8 @@
+2020-05-17  Tom Tromey  <tromey@adacore.com>
+
+       Pushed by Joel Brobecker  <brobecker@adacore.com>
+       * symfile.c (symbol_file_add_separate): Preserve OBJF_MAINLINE.
+
 2020-03-03  Sergio Durigan Junior  <sergiodj@redhat.com>
 
        PR gdb/25650
index 8fb0c9cb8452bf0b2acd44d047aada943d10dc3a..a2d9980e3c9171fe83762e48138140f2fd3d3d21 100644 (file)
@@ -1176,7 +1176,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);
 }