[Lldb-commits] [PATCH] D97786: LLDB: Use path relative to binary, not relative to debugger CWD, for finding .dwo files.

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 16 05:56:44 PDT 2021


labath added a comment.

It looks like you've managed to find a bug in lldb. Congratulations. ;)

I don't yet fully understand what's going on, but the rough idea is this: Lldb relies heavily on knowing the boundaries of every function. For this reason, our ELF code contains logic to parse the unwind info for an object file, and use it to create fake (synthetic) symbols if we don't have real ones (ObjectFileELF::ParseUnwindSymbols). The first bug is that it tries to create a new symbol for the unwind info of main. This is probably due to incomplete handling of unlinked files. The second bug is that the code assigns `symtab.size()` as the ID of the new symbol. This is a problem, because the symtab can contain real symbols with IDs larger than that (because we skip some useless symbols when creating lldb Symbol objects). This seems to be the case with this test file which contains an undefined STT_NOTYPE symbol as a first entry.  (I'm not sure why is that the case, nor if this is specific to this test file). In any case, the result of all this is that we end up with two symbols with ID 12 ("x", and the synthetic one) and we end up picking one nondeterministically when resolving relocations for `x`.

In this case, windows actually chooses the right symbol, which is why it correctly ends up printing `x = 10`. On linux, we pick the wrong one, and `x` ends up pointing to a random block of zeroes.

I'm going to look into these issues, but for the time being, you can just work around the issue by removing the `main` function, which will stop all of these bad things from happening. I have attached a reduced version of this test file, which should work correctly everywhere. (Strictly speaking, it would've been enough to remove the .cfi directives, but while I was in there, I took the opportunity to remove other unnecessary cruft as well)

F16352196: dwo-relative-path.s <https://reviews.llvm.org/F16352196>


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97786/new/

https://reviews.llvm.org/D97786



More information about the lldb-commits mailing list