public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix infinite recursion bug at get_msymbol_address.
@ 2019-11-07  4:05 Ali Tamur via gdb-patches
  2019-11-13 18:34 ` Ali Tamur via gdb-patches
  2019-11-19  5:15 ` Simon Marchi
  0 siblings, 2 replies; 6+ messages in thread
From: Ali Tamur via gdb-patches @ 2019-11-07  4:05 UTC (permalink / raw)
  To: gdb-patches; +Cc: tom, Ali Tamur

The patch 4b610737f0 seems to have introduced the possibility of infinite
recursion. I have encountered the problem while debugging a failing in-house
test. I am sorry, it is fairly difficult to reduce the test case (and I don't
understand most of what is going on) but the stack trace shows a call to
objfpy_add_separate_debug_file, which eventually causes
lookup_minimal_symbol_by_pc_name to be invoked, which calls get_msymbol_address.
Somehow lookup_minimal_symbol_linkage finds the same symbol and the function
calls itself with the same parameters. I don't know whether this should be
classified as 'it should never happen', but this simple patch makes the test
pass and should be harmless, I think.

gdb/ChangeLog

	* symtab.c (get_msymbol_address): Guard against infinite recursion.
---
 gdb/symtab.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/symtab.c b/gdb/symtab.c
index 2c934b9c22..b231cc6e84 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -6328,7 +6328,7 @@ get_msymbol_address (struct objfile *objf, const struct minimal_symbol *minsym)
 	{
 	  bound_minimal_symbol found
 	    = lookup_minimal_symbol_linkage (linkage_name, objfile);
-	  if (found.minsym != nullptr)
+	  if (found.minsym != nullptr && found.minsym != minsym)
 	    return BMSYMBOL_VALUE_ADDRESS (found);
 	}
     }
-- 
2.24.0.rc1.363.gb1bccd3e3d-goog

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-11-20  0:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-07  4:05 [PATCH] Fix infinite recursion bug at get_msymbol_address Ali Tamur via gdb-patches
2019-11-13 18:34 ` Ali Tamur via gdb-patches
2019-11-19  3:47   ` Ali Tamur via gdb-patches
2019-11-19  5:15 ` Simon Marchi
2019-11-20  0:03   ` Ali Tamur via gdb-patches
2019-11-20  0:35     ` 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).