CppSharp icon indicating copy to clipboard operation
CppSharp copied to clipboard

Segfault when parsing headers

Open Maxwell175 opened this issue 2 years ago • 0 comments

Brief Description

I am working on making bindings for a C++ game engine called Panda3D. When I feed in the built SOs and headers, CppSharp simply segfaults in the ParseHeaders function with the traceback below with no indication of what file it was on.

After further debugging by looking at the strace output, I can try to guess what file it failed on: https://gist.github.com/Maxwell175/d475185b6f767723d1f8288f7fc752f2

OS: Windows / OS X / Linux (include version and/or distro) Manjaro Linux

Used headers

There are many. https://github.com/Maxwell175/Panda3D.Net/tree/master/panda3d-build/include/panda3d

Used settings

https://github.com/Maxwell175/Panda3D.Net/blob/master/Panda3D.Net_Generator/Panda3DLibrary.cs

Stack trace or incompilable generated code
#0  0x00007fbec06cd2c1 in clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const ()
   from /home/maxwell/RiderProjects/Panda3D.Net/Panda3D.Net_Generator/bin/Debug/net7.0/runtimes/linux-x64/native/libCppSharp.CppParser.so
#1  0x00007fbec03d8de5 in clang::ASTContext::getTypeInfoImpl(clang::Type const*) const ()
   from /home/maxwell/RiderProjects/Panda3D.Net/Panda3D.Net_Generator/bin/Debug/net7.0/runtimes/linux-x64/native/libCppSharp.CppParser.so
#2  0x00007fbec03c9cd2 in clang::ASTContext::getTypeInfo(clang::Type const*) const ()
   from /home/maxwell/RiderProjects/Panda3D.Net/Panda3D.Net_Generator/bin/Debug/net7.0/runtimes/linux-x64/native/libCppSharp.CppParser.so
#3  0x00007fbec03c9cd2 in clang::ASTContext::getTypeInfo(clang::Type const*) const ()
   from /home/maxwell/RiderProjects/Panda3D.Net/Panda3D.Net_Generator/bin/Debug/net7.0/runtimes/linux-x64/native/libCppSharp.CppParser.so
#4  0x00007fbebef738b9 in clang::ASTContext::getTypeInfo (T=..., this=0x55556b310d10) at ../../llvm/llvm-791523-linux-x64-gcc-10-Release/clang/include/clang/AST/Type.h:693
#5  clang::ASTContext::getTypeSize (T=..., this=0x55556b310d10) at ../../llvm/llvm-791523-linux-x64-gcc-10-Release/clang/include/clang/AST/ASTContext.h:2258
#6  CppSharp::CppParser::Parser::WalkType (this=this@entry=0x555561320ae0, QualType=..., TL=TL@entry=0x7fffffffbb50, DesugarType=DesugarType@entry=false) at ../../../src/CppParser/Parser.cpp:2453
#7  0x00007fbebef74153 in CppSharp::CppParser::Parser::GetQualifiedType (this=0x555561320ae0, qual=..., TL=0x7fffffffbb50) at ../../../src/CppParser/Parser.cpp:591
#8  0x00007fbebef78e2a in CppSharp::CppParser::Parser::WalkVariable (this=this@entry=0x555561320ae0, VD=VD@entry=0x55556f524288, Var=Var@entry=0x555570e4b650) at ../../../src/CppParser/Parser.cpp:3493
#9  0x00007fbebef79015 in CppSharp::CppParser::Parser::WalkVariable (this=0x555561320ae0, VD=VD@entry=0x55556f524288) at ../../../src/CppParser/Parser.cpp:3513
#10 0x00007fbebef6f46a in CppSharp::CppParser::Parser::WalkDeclaration (this=this@entry=0x555561320ae0, D=D@entry=0x55556f524288) at ../../../src/CppParser/Parser.cpp:4187
#11 0x00007fbebef7898b in CppSharp::CppParser::Parser::WalkRecord (this=this@entry=0x555561320ae0, Record=Record@entry=0x55556f523148, RC=RC@entry=0x555570e45980)
    at ../../../src/CppParser/Parser.cpp:1097
#12 0x00007fbebef6db67 in CppSharp::CppParser::Parser::WalkRecordCXX (this=0x555561320ae0, Record=0x55556f523148, RC=0x555570e45980) at ../../../src/CppParser/Parser.cpp:1113
--Type <RET> for more, q to quit, c to continue without paging--c
#13 0x00007fbebef710f3 in CppSharp::CppParser::Parser::WalkRecordCXX (this=0x555561320ae0, Record=Record@entry=0x55556f523148) at ../../../src/CppParser/Parser.cpp:841
#14 0x00007fbebef6f3eb in CppSharp::CppParser::Parser::WalkDeclaration (this=this@entry=0x555561320ae0, D=D@entry=0x55556f523148) at ../../../src/CppParser/Parser.cpp:4010
#15 0x00007fbebef7a3e5 in CppSharp::CppParser::Parser::WalkDeclarationDef (this=this@entry=0x555561320ae0, D=D@entry=0x55556f523148) at ../../../src/CppParser/Parser.cpp:3975
#16 0x00007fbebef7aa53 in CppSharp::CppParser::Parser::WalkAST (this=0x555561320ae0, TU=<optimized out>) at ../../../src/CppParser/Parser.cpp:3474
#17 0x00007fbebf8ab9f9 in clang::ParseAST(clang::Sema&, bool, bool) ()
   from /home/maxwell/RiderProjects/Panda3D.Net/Panda3D.Net_Generator/bin/Debug/net7.0/runtimes/linux-x64/native/libCppSharp.CppParser.so
#18 0x00007fbebef68afe in CppSharp::CppParser::Parser::Parse (this=0x555561320ae0, SourceFiles=std::vector of length -1409, capacity -1408 = {...}) at /usr/include/c++/10/bits/unique_ptr.h:173
#19 0x00007fbebef68d5e in CppSharp::CppParser::ClangParser::ParseHeader (Opts=0x555555618300) at ../../../src/CppParser/Parser.cpp:4766
#20 0x00007fff78c982b7 in ?? ()
 <snip (no symbols after this)>

Maxwell175 avatar Sep 18 '23 05:09 Maxwell175