[all-commits] [llvm/llvm-project] 7e49b0: [lldb] Fix nullptr dereference on running x86 bina...

Daniil Kovalev via All-commits all-commits at lists.llvm.org
Mon Apr 15 23:53:55 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7e49b0d5a67f212e84f8ec0ec2e39a6a8673bfaf
      https://github.com/llvm/llvm-project/commit/7e49b0d5a67f212e84f8ec0ec2e39a6a8673bfaf
  Author: Daniil Kovalev <dkovalev at accesssoftek.com>
  Date:   2024-04-16 (Tue, 16 Apr 2024)

  Changed paths:
    M lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
    M lldb/unittests/UnwindAssembly/CMakeLists.txt
    A lldb/unittests/UnwindAssembly/x86-but-no-x86-target/CMakeLists.txt
    A lldb/unittests/UnwindAssembly/x86-but-no-x86-target/Testx86AssemblyInspectionEngine.cpp

  Log Message:
  -----------
  [lldb] Fix nullptr dereference on running x86 binary with x86-disabled llvm (#82603)

If `LLVM_TARGETS_TO_BUILD` does not contain `X86` and we try to run an
x86 binary in lldb, we get a `nullptr` dereference in
`LLVMDisasmInstruction(...)`. We try to call `getDisAsm()` method on a
`LLVMDisasmContext *DC` which is null. The pointer is passed from
`x86AssemblyInspectionEngine::instruction_length(...)` and is originally
`m_disasm_context` member of `x86AssemblyInspectionEngine`. This should
be filled by `LLVMCreateDisasm(...)` in the class constructor, but not
having X86 target enabled in llvm makes
`TargetRegistry::lookupTarget(...)` call return `nullptr`, which results
in `m_disasm_context` initialized with `nullptr` as well.

This patch adds if statements against `m_disasm_context` in
`x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(...)`
and `x86AssemblyInspectionEngine::FindFirstNonPrologueInstruction(...)`
so subsequent calls to
`x86AssemblyInspectionEngine::instruction_length(...)` do not cause a
null pointer dereference.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list