* [PATCH 0/2] Avoid infinite recursion in get_msymbol_address @ 2020-04-03 16:58 Tom Tromey 2020-04-03 16:58 ` [PATCH 1/2] Skip separate debug files when handling copy relocations Tom Tromey ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Tom Tromey @ 2020-04-03 16:58 UTC (permalink / raw) To: gdb-patches Here's a couple of patches to fix up get_msymbol_address, including fixing the infinite recursion bug. Let me know what you think. Tom ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] Skip separate debug files when handling copy relocations 2020-04-03 16:58 [PATCH 0/2] Avoid infinite recursion in get_msymbol_address Tom Tromey @ 2020-04-03 16:58 ` Tom Tromey 2020-04-03 16:58 ` [PATCH 2/2] Avoid infinite recursion in get_msymbol_address Tom Tromey 2020-04-10 13:18 ` [PATCH 0/2] Avoid infinite recursion in get_msymbol_address Tom Tromey 2 siblings, 0 replies; 6+ messages in thread From: Tom Tromey @ 2020-04-03 16:58 UTC (permalink / raw) To: gdb-patches; +Cc: Tom Tromey get_symbol_address and get_msymbol_address call lookup_minimal_symbol_linkage, which iterates over the separate debug files of the objfile that is passed in. This means that if these functions pass in a separate debug objfile, then they are doing unnecessary work. This patch avoids the extra work by skipping separate debug objfiles in the loops. gdb/ChangeLog 2020-04-03 Tom Tromey <tromey@adacore.com> * symtab.c (get_symbol_address, get_msymbol_address): Skip separate debug files. --- gdb/ChangeLog | 5 +++++ gdb/symtab.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index 5f07f3cc93e..13a5a108e6f 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -6438,6 +6438,9 @@ get_symbol_address (const struct symbol *sym) for (objfile *objfile : current_program_space->objfiles ()) { + if (objfile->separate_debug_objfile_backlink != nullptr) + continue; + bound_minimal_symbol minsym = lookup_minimal_symbol_linkage (linkage_name, objfile); if (minsym.minsym != nullptr) @@ -6458,7 +6461,8 @@ get_msymbol_address (struct objfile *objf, const struct minimal_symbol *minsym) for (objfile *objfile : current_program_space->objfiles ()) { - if ((objfile->flags & OBJF_MAINLINE) != 0) + if (objfile->separate_debug_objfile_backlink == nullptr + && (objfile->flags & OBJF_MAINLINE) != 0) { bound_minimal_symbol found = lookup_minimal_symbol_linkage (linkage_name, objfile); -- 2.21.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] Avoid infinite recursion in get_msymbol_address 2020-04-03 16:58 [PATCH 0/2] Avoid infinite recursion in get_msymbol_address Tom Tromey 2020-04-03 16:58 ` [PATCH 1/2] Skip separate debug files when handling copy relocations Tom Tromey @ 2020-04-03 16:58 ` Tom Tromey 2020-05-17 16:39 ` FYI: pushed/gdb-9.2: [PATCH 2/2] Avoid infinite recursion in get_msymbol_address") Joel Brobecker 2020-04-10 13:18 ` [PATCH 0/2] Avoid infinite recursion in get_msymbol_address Tom Tromey 2 siblings, 1 reply; 6+ messages in thread From: Tom Tromey @ 2020-04-03 16:58 UTC (permalink / raw) To: gdb-patches; +Cc: Tom Tromey 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-03 Tom Tromey <tromey@adacore.com> * symfile.c (symbol_file_add_separate): Preserve OBJF_MAINLINE. --- gdb/ChangeLog | 4 ++++ gdb/symfile.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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); } -- 2.21.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* FYI: pushed/gdb-9.2: [PATCH 2/2] Avoid infinite recursion in get_msymbol_address") 2020-04-03 16:58 ` [PATCH 2/2] Avoid infinite recursion in get_msymbol_address Tom Tromey @ 2020-05-17 16:39 ` Joel Brobecker 0 siblings, 0 replies; 6+ messages in thread From: Joel Brobecker @ 2020-05-17 16:39 UTC (permalink / raw) To: Tom Tromey, Christian Biesinger; +Cc: gdb-patches Hello, Just a quick message to let everyone know that I pushed this patch to gdb-9-branch. For that, I created PR symtab/26003. The patch was re-tested on x86_64-linux in gdb-9-branch prior to pushing. On Fri, Apr 03, 2020 at 10:58:38AM -0600, Tom Tromey wrote: > 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-03 Tom Tromey <tromey@adacore.com> > > * symfile.c (symbol_file_add_separate): Preserve OBJF_MAINLINE. > --- > gdb/ChangeLog | 4 ++++ > gdb/symfile.c | 2 +- > 2 files changed, 5 insertions(+), 1 deletion(-) > > 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); > } > > -- > 2.21.1 -- Joel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] Avoid infinite recursion in get_msymbol_address 2020-04-03 16:58 [PATCH 0/2] Avoid infinite recursion in get_msymbol_address Tom Tromey 2020-04-03 16:58 ` [PATCH 1/2] Skip separate debug files when handling copy relocations Tom Tromey 2020-04-03 16:58 ` [PATCH 2/2] Avoid infinite recursion in get_msymbol_address Tom Tromey @ 2020-04-10 13:18 ` Tom Tromey 2020-04-10 14:46 ` Simon Marchi 2 siblings, 1 reply; 6+ messages in thread From: Tom Tromey @ 2020-04-10 13:18 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches >>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes: Tom> Here's a couple of patches to fix up get_msymbol_address, including Tom> fixing the infinite recursion bug. I'm checking this in now. Tom ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] Avoid infinite recursion in get_msymbol_address 2020-04-10 13:18 ` [PATCH 0/2] Avoid infinite recursion in get_msymbol_address Tom Tromey @ 2020-04-10 14:46 ` Simon Marchi 0 siblings, 0 replies; 6+ messages in thread From: Simon Marchi @ 2020-04-10 14:46 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches, Ali Tamur On 2020-04-10 9:18 a.m., Tom Tromey wrote: >>>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes: > > Tom> Here's a couple of patches to fix up get_msymbol_address, including > Tom> fixing the infinite recursion bug. > > I'm checking this in now. > > Tom A bit late, but let me ask Ali, does this patch fix the problem you were trying to fix with this patch that you sent earlier? https://sourceware.org/legacy-ml/gdb-patches/2019-11/msg00199.html Simon ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-05-17 16:39 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-04-03 16:58 [PATCH 0/2] Avoid infinite recursion in get_msymbol_address Tom Tromey 2020-04-03 16:58 ` [PATCH 1/2] Skip separate debug files when handling copy relocations Tom Tromey 2020-04-03 16:58 ` [PATCH 2/2] Avoid infinite recursion in get_msymbol_address Tom Tromey 2020-05-17 16:39 ` FYI: pushed/gdb-9.2: [PATCH 2/2] Avoid infinite recursion in get_msymbol_address") Joel Brobecker 2020-04-10 13:18 ` [PATCH 0/2] Avoid infinite recursion in get_msymbol_address Tom Tromey 2020-04-10 14:46 ` Simon Marchi
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).