Issue |
121014
|
Summary |
Trying TySan: assert trying to build cmake: "Cannot get layout of forward declarations!"
|
Labels |
new issue
|
Assignees |
|
Reporter |
seanm
|
Was excited to see in llvm-weekly that TySan is in master, so I gave it a try. I built clang and confirmed that build of clang could build my code. Then I added `-fsanitize=type` and rebuilt, and now I get an assert:
```
Assertion failed: (D && "Cannot get layout of forward declarations!"), function getASTRecordLayout, file RecordLayoutBuilder.cpp, line 3346.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /Users/sean/llvm/llvm-install/bin/clang++ -DLIBARCHIVE_STATIC -I/Users/sean/external/cmake-bin/Utilities -I/Users/sean/external/cmake-bin/Source -I/Users/sean/external/cmake/Source -I/Users/sean/external/cmake/Source/LexerParser -isystem /Users/sean/external/cmake/Utilities/std -isystem /Users/sean/external/cmake/Utilities -fsanitize=type -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W -Wshadow -Wpointer-arith -Wformat-security -Wundef -std=c++17 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -mmacosx-version-min=14.7 -MD -MT Source/CMakeFiles/CMakeLib.dir/cmCMakeHostSystemInformationCommand.cxx.o -MF CMakeFiles/CMakeLib.dir/cmCMakeHostSystemInformationCommand.cxx.o.d -o CMakeFiles/CMakeLib.dir/cmCMakeHostSystemInformationCommand.cxx.o -c /Users/sean/external/cmake/Source/cmCMakeHostSystemInformationCommand.cxx
1. <eof> parser at end of file
2. Per-file LLVM IR generation
3. /Users/sean/external/cmake/Source/cmCMakeHostSystemInformationCommand.cxx:566:6: Generating code for declaration '(anonymous namespace)::QueryWindowsRegistry'
[ 70%] Building CXX object Source/CMakeFiles/CMakeLib.dir/cmExecProgramCommand.cxx.o
#0 0x0000000106c2d960 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102345960)
#1 0x0000000106c2be7c llvm::sys::RunSignalHandlers() (/Users/sean/llvm/llvm-install/bin/clang-20+0x102343e7c)
#2 0x0000000106c2d158 llvm::sys::CleanupOnSignal(unsigned long) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102345158)
#3 0x0000000106b90d70 CrashRecoverySignalHandler(int) (/Users/sean/llvm/llvm-install/bin/clang-20+0x1022a8d70)
#4 0x0000000193f5e584 (/usr/lib/system/libsystem_platform.dylib+0x18047a584)
#5 0x0000000193f2dc20 (/usr/lib/system/libsystem_pthread.dylib+0x180449c20)
#6 0x0000000193e3aa30 (/usr/lib/system/libsystem_c.dylib+0x180356a30)
#7 0x0000000193e39d20 (/usr/lib/system/libsystem_c.dylib+0x180355d20)
#8 0x00000001095d125c clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (.cold.3) (/Users/sean/llvm/llvm-install/bin/clang-20+0x104ce925c)
#9 0x0000000109045510 clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/Users/sean/llvm/llvm-install/bin/clang-20+0x10475d510)
#10 0x0000000108b7e6c0 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/Users/sean/llvm/llvm-install/bin/clang-20+0x1042966c0)
#11 0x0000000108b7f6a8 clang::ASTContext::getTypeInfo(clang::Type const*) const (/Users/sean/llvm/llvm-install/bin/clang-20+0x1042976a8)
#12 0x0000000108b7f564 clang::ASTContext::getTypeInfoInChars(clang::Type const*) const (/Users/sean/llvm/llvm-install/bin/clang-20+0x104297564)
#13 0x0000000108b7fc3c clang::ASTContext::getTypeSizeInChars(clang::Type const*) const (/Users/sean/llvm/llvm-install/bin/clang-20+0x104297c3c)
#14 0x00000001073b66ec clang::CodeGen::CodeGenTBAA::getTypeInfoHelper(clang::Type const*) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102ace6ec)
#15 0x00000001073b70f4 clang::CodeGen::CodeGenTBAA::getTypeInfo(clang::QualType) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102acf0f4)
#16 0x0000000107402274 clang::CodeGen::SanitizerMetadata::reportGlobal(llvm::GlobalVariable*, clang::SourceLocation, llvm::StringRef, clang::QualType, clang::SanitizerMask, bool) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102b1a274)
#17 0x0000000107402550 clang::CodeGen::SanitizerMetadata::reportGlobal(llvm::GlobalVariable*, clang::VarDecl const&, bool) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102b1a550)
#18 0x000000010737aa14 clang::CodeGen::CodeGenModule::GetOrCreateLLVMGlobal(llvm::StringRef, llvm::Type*, clang::LangAS, clang::VarDecl const*, clang::CodeGen::ForDefinition_t) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102a92a14)
#19 0x000000010737cf1c clang::CodeGen::CodeGenModule::GetAddrOfGlobalVar(clang::VarDecl const*, llvm::Type*, clang::CodeGen::ForDefinition_t) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102a94f1c)
#20 0x00000001071f2954 clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*) (/Users/sean/llvm/llvm-install/bin/clang-20+0x10290a954)
#21 0x00000001071f10bc clang::CodeGen::CodeGenFunction::EmitLValueHelper(clang::Expr const*, clang::CodeGen::KnownNonNull_t) (/Users/sean/llvm/llvm-install/bin/clang-20+0x1029090bc)
#22 0x0000000107207560 void llvm::function_ref<void ()>::callback_fn<clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*, clang::CodeGen::KnownNonNull_t)::$_0>(long) (/Users/sean/llvm/llvm-install/bin/clang-20+0x10291f560)
#23 0x0000000106f7795c clang::StackExhaustionHandler::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/Users/sean/llvm/llvm-install/bin/clang-20+0x10268f95c)
#24 0x00000001071e7a80 clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*, clang::CodeGen::KnownNonNull_t) (/Users/sean/llvm/llvm-install/bin/clang-20+0x1028ffa80)
#25 0x00000001071f1228 clang::CodeGen::CodeGenFunction::EmitLValueHelper(clang::Expr const*, clang::CodeGen::KnownNonNull_t) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102909228)
#26 0x0000000107207560 void llvm::function_ref<void ()>::callback_fn<clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*, clang::CodeGen::KnownNonNull_t)::$_0>(long) (/Users/sean/llvm/llvm-install/bin/clang-20+0x10291f560)
#27 0x0000000106f7795c clang::StackExhaustionHandler::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/Users/sean/llvm/llvm-install/bin/clang-20+0x10268f95c)
#28 0x00000001071eb070 clang::CodeGen::CodeGenFunction::EmitReferenceBindingToExpr(clang::Expr const*) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102903070)
#29 0x0000000107167bc8 clang::CodeGen::CodeGenFunction::EmitCallArg(clang::CodeGen::CallArgList&, clang::Expr const*, clang::QualType) (/Users/sean/llvm/llvm-install/bin/clang-20+0x10287fbc8)
#30 0x00000001071672f0 clang::CodeGen::CodeGenFunction::EmitCallArgs(clang::CodeGen::CallArgList&, clang::CodeGen::CodeGenFunction::PrototypeWrapper, llvm::iterator_range<clang::Stmt::CastIterator<clang::Expr, clang::Expr const* const, clang::Stmt const* const>>, clang::CodeGen::CodeGenFunction::AbstractCallee, unsigned int, clang::CodeGen::CodeGenFunction::EvaluationOrder) (/Users/sean/llvm/llvm-install/bin/clang-20+0x10287f2f0)
#31 0x000000010717a9a0 clang::CodeGen::CodeGenFunction::EmitCXXConstructorCall(clang::CXXConstructorDecl const*, clang::CXXCtorType, bool, bool, clang::CodeGen::AggValueSlot, clang::CXXConstructExpr const*) (/Users/sean/llvm/llvm-install/bin/clang-20+0x1028929a0)
#32 0x0000000107214b04 clang::CodeGen::CodeGenFunction::EmitCXXConstructExpr(clang::CXXConstructExpr const*, clang::CodeGen::AggValueSlot) (/Users/sean/llvm/llvm-install/bin/clang-20+0x10292cb04)
#33 0x000000010720ca88 (anonymous namespace)::AggExprEmitter::VisitCXXConstructExpr(clang::CXXConstructExpr const*) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102924a88)
#34 0x0000000107207bc4 clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) (/Users/sean/llvm/llvm-install/bin/clang-20+0x10291fbc4)
#35 0x00000001071d3950 clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) (/Users/sean/llvm/llvm-install/bin/clang-20+0x1028eb950)
#36 0x00000001071d11a8 clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission const&) (/Users/sean/llvm/llvm-install/bin/clang-20+0x1028e91a8)
#37 0x00000001071cd72c clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (/Users/sean/llvm/llvm-install/bin/clang-20+0x1028e572c)
#38 0x00000001071cd2b8 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) (/Users/sean/llvm/llvm-install/bin/clang-20+0x1028e52b8)
#39 0x0000000107309878 clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102a21878)
#40 0x00000001073006b8 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102a186b8)
#41 0x00000001072ff16c clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102a1716c)
#42 0x000000010730a7a4 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102a227a4)
#43 0x000000010735e330 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102a76330)
#44 0x000000010737d9a8 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102a959a8)
#45 0x0000000107377630 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102a8f630)
#46 0x000000010736c90c clang::CodeGen::CodeGenModule::EmitDeferred() (/Users/sean/llvm/llvm-install/bin/clang-20+0x102a8490c)
#47 0x000000010736a3a4 clang::CodeGen::CodeGenModule::Release() (/Users/sean/llvm/llvm-install/bin/clang-20+0x102a823a4)
#48 0x00000001073ee964 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102b06964)
#49 0x00000001073505ec clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102a685ec)
#50 0x0000000108298828 clang::ParseAST(clang::Sema&, bool, bool) (/Users/sean/llvm/llvm-install/bin/clang-20+0x1039b0828)
#51 0x0000000107635344 clang::FrontendAction::Execute() (/Users/sean/llvm/llvm-install/bin/clang-20+0x102d4d344)
#52 0x00000001075d1ba8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102ce9ba8)
#53 0x00000001076a779c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102dbf79c)
#54 0x00000001048f0d28 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/Users/sean/llvm/llvm-install/bin/clang-20+0x100008d28)
#55 0x00000001048ee4d8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) (/Users/sean/llvm/llvm-install/bin/clang-20+0x1000064d8)
#56 0x0000000107466f70 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const::$_0>(long) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102b7ef70)
#57 0x0000000106b90a90 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/Users/sean/llvm/llvm-install/bin/clang-20+0x1022a8a90)
#58 0x00000001074669f8 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const (/Users/sean/llvm/llvm-install/bin/clang-20+0x102b7e9f8)
#59 0x000000010743b3d4 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/Users/sean/llvm/llvm-install/bin/clang-20+0x102b533d4)
#60 0x000000010743b59c clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&, bool) const (/Users/sean/llvm/llvm-install/bin/clang-20+0x102b5359c)
#61 0x00000001074502c4 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&) (/Users/sean/llvm/llvm-install/bin/clang-20+0x102b682c4)
#62 0x00000001048eda4c clang_main(int, char**, llvm::ToolContext const&) (/Users/sean/llvm/llvm-install/bin/clang-20+0x100005a4c)
#63 0x00000001048f8de0 main (/Users/sean/llvm/llvm-install/bin/clang-20+0x100010de0)
#64 0x0000000193ba3154
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 20.0.0git (https://github.com/seanm/llvm-project.git 1c25a3bfa57209e7a29eaae58ce5e0432aafe8c3)
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /Users/sean/llvm/llvm-install/bin
Build config: +assertions
[ 70%] Building CXX object Source/CMakeFiles/CMakeLib.dir/cmExecuteProcessCommand.cxx.o
[ 70%] Building CXX object Source/CMakeFiles/CMakeLib.dir/cmExpandedCommandArgument.cxx.o
[ 71%] Building CXX object Source/CMakeFiles/CMakeLib.dir/cmExperimental.cxx.o
[ 71%] Building CXX object Source/CMakeFiles/CMakeLib.dir/cmExportCommand.cxx.o
clang++: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /var/folders/dd/g1wv21gn4j92g56tff_60ptw0000gp/T/cmCMakeHostSystemInformationCommand-983a48.cpp
clang++: note: diagnostic msg: /var/folders/dd/g1wv21gn4j92g56tff_60ptw0000gp/T/cmCMakeHostSystemInformationCommand-983a48.sh
clang++: note: diagnostic msg: Crash backtrace is located in
clang++: note: diagnostic msg: /Users/sean/Library/Logs/DiagnosticReports/clang-20_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang++: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang++: note: diagnostic msg:
********************
make[2]: *** [Source/CMakeFiles/CMakeLib.dir/cmCMakeHostSystemInformationCommand.cxx.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [Source/CMakeFiles/CMakeLib.dir/all] Error 2
make: *** [all] Error 2
```
Requested files:
[cmCMakeHostSystemInformationCommand-983a48.zip](https://github.com/user-attachments/files/18234332/cmCMakeHostSystemInformationCommand-983a48.zip)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs