Open llvmbot opened 7 years ago
I've submitted another review request to Phabricator : https://reviews.llvm.org/D39639
@Sagi Ben Thanks for your comment.
I'm afraid the patch is intended to be a starting point for investigation, nothing more. I doubt that it would be an adequate fix without further work by someone more familiar with the Itanium ABI code.
I applied the patch on the latest clang source code.
I get assertion failed error :
/home/sagi/trees/community/clang/lib/AST/ItaniumMangle.cpp:1337: void (anonymous namespace)::CXXNameMangler::mangleUnqualifiedName(const clang::NamedDecl , clang::DeclarationName, unsigned int, const (anonymous namespace)::CXXNameMangler::AbiTagList ): Assertion `RD->isAnonymousStructOrUnion() && "Expected anonymous struct or union!"' failed.
The issue seems to be in ItaniumMangle.cpp and can be triggered on macOS by asking for mangled names from a C++ (not C) TU containing a struct with a void()(void) function pointer member.
I'm not familiar with this part of clang but have a very simple patch that might provide a useful starting point for further investigation.
Simple test (and crude fix) submitted to Phabricator as: https://reviews.llvm.org/D37639
Hi, Thanks !!
I verified that removing it from the print statement hide the crash, but should it crash with seg fault of should it throw an exception.
Sagi.
The call to node.mangled_name
is causing a crash, not sure if that might give you an interim fix.
I'll dig into why this goes wrong.
backtrace for latest libclang :
at /build/llvm-toolchain-snapshot-6.0~svn312504/tools/clang/lib/AST/ItaniumMangle.cpp:487
at /build/llvm-toolchain-snapshot-6.0~svn312504/tools/clang/lib/AST/ItaniumMangle.cpp:866
at /build/llvm-toolchain-snapshot-6.0~svn312504/tools/clang/lib/AST/ItaniumMangle.cpp:822
at /build/llvm-toolchain-snapshot-6.0~svn312504/tools/clang/lib/AST/ItaniumMangle.cpp:4686
warning: Could not find DWO CU CMakeFiles/clangIndex.dir/CodegenNameGenerator.cpp.dwo(0xf5a023084daf1c61) referenced by CU at offset 0x1884 [in module /usr/lib/debug/.build-id/71/6b13ccc5fd8b1fed075592557487fff0f3bd99.debug] warning: (Internal error: pc 0x7ffff5331008 in read in psymtab, but not in symtab.)
warning: (Internal error: pc 0x7ffff5330d70 in read in psymtab, but not in symtab.)
warning: (Internal error: pc 0x7ffff5331008 in read in psymtab, but not in symtab.)
warning: (Internal error: pc 0x7ffff5331008 in read in psymtab, but not in symtab.)
warning: (Internal error: pc 0x7ffff5331008 in read in psymtab, but not in symtab.)
at /build/llvm-toolchain-snapshot-6.0~svn312504/tools/clang/lib/Index/CodegenNameGenerator.cpp:126
warning: (Internal error: pc 0x7ffff5331008 in read in psymtab, but not in symtab.)
warning: Could not find DWO CU CMakeFiles/libclang.dir/CIndex.cpp.dwo(0xa704430e2abfdcd4) referenced by CU at offset 0x68 [in module /usr/lib/debug/.build-id/71/6b13ccc5fd8b1fed075592557487fff0f3bd99.debug]
pProc=0x7ffff506cee0 <clang_Cursor_getMangling>, flags=4353) at /build/python3.5-9imW1d/python3.5-3.5.2/Modules/_ctypes/callproc.c:811
argtypes=(<built-in method from_param of _ctypes.PyCStructType object at remote 0xb97388>,), restype=<_ctypes.PyCStructType at remote 0xb874c8>, checker=0x0)
at /build/python3.5-9imW1d/python3.5-3.5.2/Modules/_ctypes/callproc.c:1149
at /build/python3.5-9imW1d/python3.5-3.5.2/Modules/_ctypes/_ctypes.c:3856
argcount=<optimized out>, args=<optimized out>, locals=<optimized out>, globals=<optimized out>, _co=<code at remote 0x7ffff6968270>) at ../Python/ceval.c:4018
---Type
stack_end=0x7fffffffdbc8) at ../csu/libc-start.c:291
Extended Description
The full description can be found here : https://stackoverflow.com/questions/45901636/python-clang-crashes-with-segmentation-fault
While trying to traverse clang AST using python-clang bindings on bitcoin opensource project. libclang crashes with segmentation fault. At start I used libclang version 3.8 but it happens with versions 3.9, 4.0, 5.0 and 6.0 (6.0~svn312460-1~exp1)
backtrace :
0 clang::TagType::getDecl (this=0x0) at /build/llvm-toolchain-3.8-_PD09B/llvm-toolchain-3.8-3.8/tools/clang/lib/AST/Type.cpp:2962
1 0x00007f9ecbe65caf in clang::RecordType::getDecl (this=) at /build/llvm-toolchain-3.8-_PD09B/llvm-toolchain-3.8-3.8/tools/clang/include/clang/AST/Type.h:3554
2 (anonymous namespace)::CXXNameMangler::mangleUnqualifiedName (this=this@entry=0x7ffe35f45470, ND=ND@entry=0x7f9ec0092cc8, Name=...,
3 0x00007f9ecbe60250 in (anonymous namespace)::CXXNameMangler::mangleUnqualifiedName (AdditionalAbiTags=0x7ffe35f453c0, ND=, this=0x7ffe35f45470)
4 (anonymous namespace)::CXXNameMangler::mangleLocalName (this=this@entry=0x7ffe35f45470, D=D@entry=0x7f9ec0092cc8, AdditionalAbiTags=AdditionalAbiTags@entry=0x7ffe35f453c0,
5 0x00007f9ecbe607b7 in (anonymous namespace)::CXXNameMangler::mangleNameWithAbiTags (this=this@entry=0x7ffe35f45470, ND=ND@entry=0x7f9ec0092cc8,
6 0x00007f9ecbe61621 in (anonymous namespace)::CXXNameMangler::mangleName (this=0x7ffe35f45470, ND=0x7f9ec0092cc8, ExcludeUnqualifiedName=)
7 0x00007f9ecbe62822 in (anonymous namespace)::ItaniumMangleContextImpl::mangleCXXName (this=, D=0x7f9ec0092cc8, Out=...)
8 0x00007f9ecbd4df6b in clang_Cursor_getMangling (C=...) at /build/llvm-toolchain-3.8-_PD09B/llvm-toolchain-3.8-3.8/tools/clang/tools/libclang/CIndex.cpp:3996
9 0x00007f9eccbd2e40 in ffi_call_unix64 () from /usr/lib/x86_64-linux-gnu/libffi.so.6
10 0x00007f9eccbd28ab in ffi_call () from /usr/lib/x86_64-linux-gnu/libffi.so.6