Skip to content

[lldb] Crash in _PyObject_Malloc when importing lldb in a different Python interpreter #167002

@JDevlieghere

Description

@JDevlieghere

I built lldb with LLDB_ENABLE_PYTHON_LIMITED_API against Python 3.14 from python.org. I then tried to import it from Python 3.12 installed with Homebrew. That causes a crash in _PyObject_Malloc during initialization:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
    frame #0: 0x000000010879560c Python`_PyObject_Malloc + 52
Python`_PyObject_Malloc:
->  0x10879560c <+52>: ldr    x8, [x8, #0x10]
    0x108795610 <+56>: ldr    x19, [x8, #0x2aa8]
    0x108795614 <+60>: sub    x8, x1, #0x201
    0x108795618 <+64>: cmn    x8, #0x200
Target 0: (Python) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
  * frame #0: 0x000000010879560c Python`_PyObject_Malloc + 52
    frame #1: 0x0000000108803ce8 Python`PyUnicode_FromString + 548
    frame #2: 0x0000000116c16310 liblldb.22.0.0git.dylib`SWIG_Python_str_FromChar(c=<unavailable>) at LLDBWrapPython.cpp:877:10 [opt] [inlined]
    frame #3: 0x0000000116c16304 liblldb.22.0.0git.dylib`SWIG_This() at LLDBWrapPython.cpp:2473:24 [opt] [inlined]
    frame #4: 0x0000000116c162f8 liblldb.22.0.0git.dylib`::PyInit__lldb() at LLDBWrapPython.cpp:105239:3 [opt]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions