[llvm] [libDebugInfo] Prevent infinite recursion in DWARFDie::getTypeSize() (PR #74681)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 7 09:50:18 PST 2023


dwblaikie wrote:

> > A more general question: libDebugInfoDWARF isn't at all robust to "interesting" let alone invalid input - this fixes one instance, but I'm wondering what your goals are. If this bug was worth fixing, what's your use case/what else are you planning to fix/handle?
> 
> To answer this question narrowly, the kind of debug info in the test case (a self-recursive typedef) can be created by a combination of an LTO bug (which I'm trying to fix next, though it make time, because LTO) and a bug in dsymutil, and the resulting DWARF caused tooling like TAPI to crash with an infinite recursion. My goal is to just make sure that this kind of DWARF that is now out in the wild can be handled by users of libDebugInfo.
> 
> > (might be worth a broader discussion about how we might go about doing that? I'm not sure how this compares to Clang's recursion limits, for instance? Not sure if they use a similarly "visited" system, or if there's some other tools/techniques to consider?)
> 
> Generally, DWARF consumers are good at dealing with recursive types. This is a special case where the getTypeSize() method which is AFAIK not used in e.g., LLDB, didn't expect to find a self-referential type.



> > A more general question: libDebugInfoDWARF isn't at all robust to "interesting" let alone invalid input - this fixes one instance, but I'm wondering what your goals are. If this bug was worth fixing, what's your use case/what else are you planning to fix/handle?
> 
> To answer this question narrowly, the kind of debug info in the test case (a self-recursive typedef) can be created by a combination of an LTO bug (which I'm trying to fix next, though it make time, because LTO) and a bug in dsymutil, and the resulting DWARF caused tooling like TAPI to crash with an infinite recursion. My goal is to just make sure that this kind of DWARF that is now out in the wild can be handled by users of libDebugInfo.

Ah, fair enough.

> > (might be worth a broader discussion about how we might go about doing that? I'm not sure how this compares to Clang's recursion limits, for instance? Not sure if they use a similarly "visited" system, or if there's some other tools/techniques to consider?)
> 
> Generally, DWARF consumers are good at dealing with recursive types. This is a special case where the getTypeSize() method which is AFAIK not used in e.g., LLDB, didn't expect to find a self-referential type.

Huh, somewhat surprises me - but fair enough. Thanks for the context.

https://github.com/llvm/llvm-project/pull/74681


More information about the llvm-commits mailing list