This prevents infinite recursion in DWARFDie::findRecursively for
malformed DWARF where a DIE references itself.
Details
Diff Detail
Event Timeline
I'm guessing this is insufficient for catching indirect recursion (DIE A refers to DIE B and B back to A)?
Ideally/the original version of this, I think was non-recursive and only specifically looked for certain attributes in order and then stopped. I'd sort of rather than, because it's more constrained.
That's true, unfortunately. Is it worth to convert this to a worklist and keep track of the already-seen DIEs?
Ideally/the original version of this, I think was non-recursive and only specifically looked for certain attributes in order and then stopped. I'd sort of rather than, because it's more constrained.
The original find() still exists, so I'd expect this variant only to be used where the recursive property is needed.
Ideally/the original version of this, I think was non-recursive and only specifically looked for certain attributes in order and then stopped. I'd sort of rather than, because it's more constrained.
The original find() still exists, so I'd expect this variant only to be used where the recursive property is needed.
'find()' only searches the current DIE. findRecursively is needed when looking through abstract or specification references - but these aren't, so far as I know, arbitrarily nested (you can't have an unlimited chain of abstract/specifications - really you can only have at most one of each, in a specific order (abstract then specification) - as far as I recall/know). So unlimited recursion is a bit overpowered here.
Could you check the revision history here? I'm pretty sure the first version of this I reviewed from Greg wasn't recursive - and then it became recursive at some point to handle something needed, but maybe those decisions need to be reexamined?
It was @clayborg himself that updated the implementation. (D40156 rL319104)
The previous implementation would only look 1 DW_AT_specification or DW_AT_abstract_origin deep. This means DWARFDie::getName() would fail in certain cases. I ran into such a case while creating a tool that used the LLVM DWARF parser to generate a symbolication format so I have seen this in the wild.
Use SmallSet<DWARFDie, 3> (running dsymutil over clang showed that there were never more than 3 elements in the set for valid DWARF).
Thanks for checking!
llvm/lib/DebugInfo/DWARF/DWARFDie.cpp | ||
---|---|---|
300 | Perhaps add a comment explaining that this avoids infinite recursion on malformed input and empirically we never have a depth>3 ? |
Sorry - could we revisit this?
I think my concerns expressed still haven't been resolved:
"Could you check the revision history here? I'm pretty sure the first
version of this I reviewed from Greg wasn't recursive - and then it became
recursive at some point to handle something needed, but maybe those
decisions need to be reexamined?" (& related comments back there)
Perhaps add a comment what this means?