wlav / cppyy

Other
413 stars 42 forks source link

Crash on a cppdef #275

Open amal-khailtash opened 2 weeks ago

amal-khailtash commented 2 weeks ago

I am trying to load a number of header files and I use cppdef, but I see this crash. Unfortunately, I cannot share the header files, but I can try and debug this if you have switches, or other ways to debug.

#0  0x00002b82d0cae60c in waitpid () from /lib64/libc.so.6
#1  0x00002b82d0c2bf62 in do_system () from /lib64/libc.so.6
#2  0x00002b82d7de3c15 in CppyyLegacy::TUnixSystem::StackTrace() () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCoreLegacy.so
#3  0x00002b82d7a1de12 in (anonymous namespace)::TExceptionHandlerImp::HandleException(int) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libcppyy_backend.so
#4  0x00002b82d7de26f1 in CppyyLegacy::TUnixSystem::DispatchSignals(CppyyLegacy::ESignals) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCoreLegacy.so
#5  <signal handler called>
#6  0x00002b82dc656bd0 in clang::Decl::getTranslationUnitDecl() [clone .part.0] () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#7  0x00002b82dc6603fe in clang::DeclContext::removeDecl(clang::Decl*) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#8  0x00002b82d9a6fa36 in cling::DeclUnloader::VisitNamedDecl(clang::NamedDecl*) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#9  0x00002b82d9a6fafc in cling::DeclUnloader::VisitDeclaratorDecl(clang::DeclaratorDecl*) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#10 0x00002b82d9a6fd60 in cling::DeclUnloader::VisitVarDecl(clang::VarDecl*) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#11 0x00002b82d9a7d2fc in cling::DeclUnloader::VisitDeclContext(clang::DeclContext*) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#12 0x00002b82d9a7c4df in cling::DeclUnloader::VisitFunctionDecl(clang::FunctionDecl*) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#13 0x00002b82d9a7d2fc in cling::DeclUnloader::VisitDeclContext(clang::DeclContext*) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#14 0x00002b82d9a7df7c in cling::DeclUnloader::VisitRecordDecl(clang::RecordDecl*) [clone .part.0] () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#15 0x00002b82d9a7e6a7 in cling::DeclUnloader::VisitClassTemplateDecl(clang::ClassTemplateDecl*) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#16 0x00002b82d9a38334 in cling::TransactionUnloader::unloadDeclarations(cling::Transaction*, cling::DeclUnloader&) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#17 0x00002b82d9a385e4 in cling::TransactionUnloader::RevertTransaction(cling::Transaction*) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#18 0x00002b82d9a18e78 in cling::Interpreter::unload(cling::Transaction&) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#19 0x00002b82d9abcab0 in cling::IncrementalParser::commitTransaction(llvm::PointerIntPair<cling::Transaction*, 2u, cling::IncrementalParser::EParseResult, llvm::PointerLikeTypeTraits<cling::Transaction*>, llvm::PointerIntPairInfo<cling::Transaction*, 2u, llvm::PointerLikeTypeTraits<cling::Transaction*> > >&, bool) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#20 0x00002b82d9ac06f9 in cling::IncrementalParser::Compile(llvm::StringRef, cling::CompilationOptions const&) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#21 0x00002b82d9a1b8d2 in cling::Interpreter::declare(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::Transaction**) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#22 0x00002b82d9928e0f in CppyyLegacy::TCling::Declare(char const*, bool) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#23 0x00002b82e1ccd033 in ?? ()
#24 0x00007ffd13b6c628 in ?? ()
#25 0x00007ffd13b6c940 in ?? ()
#26 0x0000000000000000 in ?? ()
#0  0x00002b82d0cae60c in waitpid () from /lib64/libc.so.6
#1  0x00002b82d0c2bf62 in do_system () from /lib64/libc.so.6
#2  0x00002b82d7de3c15 in CppyyLegacy::TUnixSystem::StackTrace() () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCoreLegacy.so
#3  0x00002b82d7a1dc9a in (anonymous namespace)::TExceptionHandlerImp::HandleException(int) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libcppyy_backend.so
#4  0x00002b82d7de26f1 in CppyyLegacy::TUnixSystem::DispatchSignals(CppyyLegacy::ESignals) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCoreLegacy.so
#5  <signal handler called>
#6  0x00002b82dc656bd0 in clang::Decl::getTranslationUnitDecl() [clone .part.0] () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#7  0x00002b82dc6603fe in clang::DeclContext::removeDecl(clang::Decl*) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#8  0x00002b82d9a6fa36 in cling::DeclUnloader::VisitNamedDecl(clang::NamedDecl*) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#9  0x00002b82d9a6fafc in cling::DeclUnloader::VisitDeclaratorDecl(clang::DeclaratorDecl*) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#10 0x00002b82d9a6fd60 in cling::DeclUnloader::VisitVarDecl(clang::VarDecl*) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#11 0x00002b82d9a7d2fc in cling::DeclUnloader::VisitDeclContext(clang::DeclContext*) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#12 0x00002b82d9a7c4df in cling::DeclUnloader::VisitFunctionDecl(clang::FunctionDecl*) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#13 0x00002b82d9a7d2fc in cling::DeclUnloader::VisitDeclContext(clang::DeclContext*) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#14 0x00002b82d9a7df7c in cling::DeclUnloader::VisitRecordDecl(clang::RecordDecl*) [clone .part.0] () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#15 0x00002b82d9a7e6a7 in cling::DeclUnloader::VisitClassTemplateDecl(clang::ClassTemplateDecl*) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#16 0x00002b82d9a38334 in cling::TransactionUnloader::unloadDeclarations(cling::Transaction*, cling::DeclUnloader&) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#17 0x00002b82d9a385e4 in cling::TransactionUnloader::RevertTransaction(cling::Transaction*) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#18 0x00002b82d9a18e78 in cling::Interpreter::unload(cling::Transaction&) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#19 0x00002b82d9abcab0 in cling::IncrementalParser::commitTransaction(llvm::PointerIntPair<cling::Transaction*, 2u, cling::IncrementalParser::EParseResult, llvm::PointerLikeTypeTraits<cling::Transaction*>, llvm::PointerIntPairInfo<cling::Transaction*, 2u, llvm::PointerLikeTypeTraits<cling::Transaction*> > >&, bool) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#20 0x00002b82d9ac06f9 in cling::IncrementalParser::Compile(llvm::StringRef, cling::CompilationOptions const&) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#21 0x00002b82d9a1b8d2 in cling::Interpreter::declare(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::Transaction**) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#22 0x00002b82d9928e0f in CppyyLegacy::TCling::Declare(char const*, bool) () from .venv/lib/python3.12/site-packages/cppyy_backend/lib/libCling.so
#23 0x00002b82e1ccd033 in ?? ()
#24 0x00007ffd13b6c628 in ?? ()
#25 0x00007ffd13b6c940 in ?? ()
#26 0x0000000000000000 in ?? ()

Is this a cling issue maybe?

wlav commented 1 week ago

Yes, would be on Cling; never seen it crash like that before, though. Given that it's unloading code, I presume there was a different error first, which caused the transaction to be rolled back.

Which C++ standard do you need? Default is 20 (as far as supported by Clang13). If 17 will do, then maybe moving to that standard makes the cause of the unloading go away. Something like:

export EXTRA_CLING_ARGS='-O2 -march=native -std=c++17'
export CLING_REBUILD_PCH=1

(The second envar should be unset after the PCH was rebuild on first use.)

Aside, I'm 3 failing tests away from moving to Clang16, so if this is indeed a parsing issue, that move may solve it.