Bug 30822 - [gdb/symtab] Handle cyclic DIE references
Summary: [gdb/symtab] Handle cyclic DIE references
Status: NEW
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: 2023-09-04 11:41 UTC by Tom de Vries
Modified: 2023-09-04 11:41 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2023-09-04 11:41:30 UTC
There are a few fixes in place in gdb/dwarf2/read.c that deal with self-referencing DIEs:
...
$ grep -i self-ref gdb/dwarf2/read.c
	      /* Handle DIE with self-reference.  */
      /* Self-referential typedefs are, it seems, not allowed by the DWARF
      complaint (_("Self-referential DW_TAG_typedef "
	      /* Self-reference, we're done.  */
	/* Self-reference, we're done.  */
      /* Self-reference, we're done.  */
...

These prevent either a hang or running out of stack.

The generic case of cyclic DIE references (for instance DIE A references DIE B, DIE B references DIE A) hasn't been solved though.

Tom Tromey mentioned using a tortoise/hare approach to detect the cycles here ( https://sourceware.org/pipermail/gdb-patches/2023-August/201921.html ).

See https://en.wikipedia.org/wiki/Cycle_detection#Floyd's_tortoise_and_hare .