Skip to content

SIGSEGV on getTypdefName on invalid type #123763

Open
@zokrezyl

Description

@zokrezyl

Hi,

am getting the following SIGSEGV when using python clang.cindex, (libclang.so.19.1.7) with python 3.13.1. Am parsing a huge codebase, could not identify exactly the type/typedef context, but likely the exception(al) situation could be handled better in libclang.

only context I can provide is

<clang.cindex.Type object at 0x7fd4c3f67bd0> <class 'clang.cindex.Type'>  TypeKind.INVALID

while the type object is obviously "invalid", it is returned by one of the other methods on cursor or type. Other methods on this invalid type object do not cause sisgegv, so would expect this one also to return null/none or so.

Thanks and Regards,
Z

    frame #0: 0x00007ffff43dd043 libclang.so.19.1.7`clang_getTypedefName + 35
libclang.so.19.1.7`clang_getTypedefName:
->  0x7ffff43dd043 <+35>: movq   (%rax), %rdi
    0x7ffff43dd046 <+38>: callq  0x7ffff481a360 ; clang::TypedefType const* clang::Type::getAs<clang::TypedefType>() const
    0x7ffff43dd04b <+43>: testq  %rax, %rax
    0x7ffff43dd04e <+46>: je     0x7ffff43dd0b0 ; <+144>
(lldb) bt
* thread #1, name = 'python3', stop reason = signal SIGSEGV: address not mapped to object (fault address: 0x0)
  * frame #0: 0x00007ffff43dd043 libclang.so.19.1.7`clang_getTypedefName + 35
    frame #1: 0x00007ffff7357056 libffi.so.8`ffi_call_unix64 + 86
    frame #2: 0x00007ffff7355af9 libffi.so.8`ffi_call_int + 489
    frame #3: 0x00007ffff7356363 libffi.so.8`ffi_call + 291
    frame #4: 0x00007ffff736f473 _ctypes.cpython-313-x86_64-linux-gnu.so`_ctypes_callproc.cold + 751
    frame #5: 0x00007ffff73759e0 _ctypes.cpython-313-x86_64-linux-gnu.so`PyCFuncPtr_call + 336

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:as-a-librarylibclang and C++ APIcrashPrefer [crash-on-valid] or [crash-on-invalid]

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions