[Lldb-commits] [lldb] [lldb] Fix nullptr dereference on running x86 binary with x86-disabled llvm (PR #82603)

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 12 10:10:21 PDT 2024


jasonmolenda wrote:

Hi sorry @kovdan01 I missed this one in the emails.  You're using an lldb which was built without the `LLVM_TARGETS_TO_BUILD` including X86, and running that lldb on an x86 corefile, got it.  I have low confidence how well lldb will work in this situation, e.g. inferior function calls are obviously going to fail completely, and possibly not in a graceful way, but that doesn't impact corefiles.  I'm less thrilled about adding a 570kb corefile to the repository to check this combination doesn't crash the unwinder.  In lldb/unittest/UnwindAssembly we build the `x86` directory when 

```
if ("X86" IN_LIST LLVM_TARGETS_TO_BUILD)
  add_subdirectory(x86)
endif()
```

In Testx86AssemblyInspectionEngine.cpp we initialize llvm state in `Testx86AssemblyInspectionEngine::SetUpTestCase` and then run individual tests in the `TEST_F()` entries, creating a byte stream of prologues like 

```
  // 'int main() { }' compiled for x86_64-apple-macosx with clang
  uint8_t data[] = {
      0x55,             // offset 0 -- pushq %rbp
      0x48, 0x89, 0xe5, // offset 1 -- movq %rsp, %rbp
      0x31, 0xc0,       // offset 4 -- xorl %eax, %eax
      0x5d,             // offset 6 -- popq %rbp
      0xc3              // offset 7 -- retq
  };
```

and run the unwind engine on those bytes.  

Could we add a `x86-but-no-x86-target` directory, write one test to see that the unwind engine can run against a byte buffer like this and not crash instead maybe?  

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


More information about the lldb-commits mailing list