Avoid infinite recursion in get_msymbol_address
authorTom Tromey <tromey@adacore.com>
Fri, 10 Apr 2020 13:18:49 +0000 (07:18 -0600)
committerTom Tromey <tromey@adacore.com>
Fri, 10 Apr 2020 13:21:16 +0000 (07:21 -0600)
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.

gdb/ChangeLog
gdb/symfile.c

index fa05f93a5e5a46b166ab865141d06d43dee7808e..661a41467bbef9b60671137b5b74983405193d13 100644 (file)
@@ -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
index bd27a1fefef16a5723c8e50c6cf4cd8f729ea9f9..61053298a8910346502ea22538b03a03d8a76f89 100644 (file)
@@ -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);
 }
 
This page took 0.033611 seconds and 4 git commands to generate.