Bug 26289 - Infinite loop in dwarf2_attr()
Summary: Infinite loop in dwarf2_attr()
Status: UNCONFIRMED
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-23 00:36 UTC by Leandro Pereira
Modified: 2023-03-29 14:14 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Patch (version 1) (714 bytes, patch)
2020-07-23 00:36 UTC, Leandro Pereira
Details | Diff
Patch (version 1, but with the correct email address) (722 bytes, patch)
2020-07-23 00:41 UTC, Leandro Pereira
Details | Diff
Extended patch including test case (2.54 KB, patch)
2020-07-23 08:34 UTC, Andrew Burgess
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Leandro Pereira 2020-07-23 00:36:20 UTC
Created attachment 12719 [details]
Patch (version 1)

While debugging a program that dumped core (which I unfortunately can't share), GDB gets into an infinite loop inside dwarf2_attr() because the ``die'' returned by follow_die_ref() is the same one that was passed in.

Attached is a patch that addresses this issue, but I'm not familiar with GDB or DWARF enough to reason about it, so feedback would be appreciated.
Comment 1 Leandro Pereira 2020-07-23 00:41:57 UTC
Created attachment 12720 [details]
Patch (version 1, but with the correct email address)
Comment 2 Andrew Burgess 2020-07-23 08:34:21 UTC
Created attachment 12721 [details]
Extended patch including test case

This started out with me "just" writing a test case for this issue.  Unfortunately this exposed a bunch more places that needed fixing up, so this is now the original patch + a test case + some additional fixes.

This is still work-in-progress, but the code needs a clean up, and I suspect that there might be additional test cases that need to be written.
Comment 3 Tom Tromey 2020-07-23 14:03:35 UTC
FWIW it's good, when possible, to print info about which DIE is
offending.
Here's an example:
	  complaint (_("Computed physname <%s> does not match demangled <%s> "
		       "(from linkage <%s>) - DIE at %s [in module %s]"),
		     physname, canon, mangled, sect_offset_str (die->sect_off),
		     objfile_name (objfile));
That way it is sometimes simpler to track down the bug.
Comment 4 Tom Tromey 2023-03-29 14:14:19 UTC
Switching components.