Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recent clang crashes trying to compile hello.cpp on Windows with opaque pointers #53089

Closed
russellw opened this issue Jan 8, 2022 · 6 comments

Comments

@russellw
Copy link

russellw commented Jan 8, 2022

Assertion failed: NumContainedTys && "Attempting to get element type of opaque pointer", file C:\llvm-project\llvm\include\llvm/IR/Type.h, line 372
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: clang -S -emit-llvm -mllvm -opaque-pointers c:\\olivine\\test\\hello.cpp
1.	<eof> parser at end of file
2.	Per-file LLVM IR generation
3.	C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\xcall_once.h:66:6: Generating code for declaration 'std::_Immortalize'
 #0 0x00007ff73fd2192c HandleAbort C:\llvm-project\llvm\lib\Support\Windows\Signals.inc:408:0
 #1 0x00007ff87883c3e1 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x6c3e1)
 #2 0x00007ff87883e039 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x6e039)
 #3 0x00007ff87884386f (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x7386f)
 #4 0x00007ff878841841 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x71841)
 #5 0x00007ff8788441cf (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x741cf)
 #6 0x00007ff73af72c6a llvm::Type::getPointerElementType(void) const C:\llvm-project\llvm\include\llvm\IR\Type.h:371:0
 #7 0x00007ff7406c16ba clang::CodeGen::Address::Address(class llvm::Value *, class clang::CharUnits) C:\llvm-project\clang\lib\CodeGen\Address.h:45:0
 #8 0x00007ff74087ca67 clang::CodeGen::CGBuilderTy::CreateBitCast(class clang::CodeGen::Address, class llvm::Type *, class llvm::Twine const &) C:\llvm-project\clang\lib\CodeGen\CGBuilder.h:156:0
 #9 0x00007ff740ab6b81 clang::CodeGen::CodeGenFunction::EmitCastLValue(class clang::CastExpr const *) C:\llvm-project\clang\lib\CodeGen\CGExpr.cpp:4769:0
#10 0x00007ff740aa9d9f clang::CodeGen::CodeGenFunction::EmitLValue(class clang::Expr const *) C:\llvm-project\clang\lib\CodeGen\CGExpr.cpp:1412:0
#11 0x00007ff740abd84b clang::CodeGen::CodeGenFunction::EmitReferenceBindingToExpr(class clang::Expr const *) C:\llvm-project\clang\lib\CodeGen\CGExpr.cpp:606:0
#12 0x00007ff74084b19b clang::CodeGen::CodeGenFunction::EmitCallArg(class clang::CodeGen::CallArgList &, class clang::Expr const *, class clang::QualType) C:\llvm-project\clang\lib\CodeGen\CGCall.cpp:4299:0
#13 0x00007ff74084d69c clang::CodeGen::CodeGenFunction::EmitCallArgs(class clang::CodeGen::CallArgList &, struct clang::CodeGen::CodeGenFunction::PrototypeWrapper, class llvm::iterator_range<struct clang::Stmt::CastIterator<class clang::Expr, class clang::Expr const *const, class clang::Stmt const *const>>, class clang::CodeGen::CodeGenFunction::AbstractCallee, unsigned int, enum clang::CodeGen::CodeGenFunction::EvaluationOrder) C:\llvm-project\clang\lib\CodeGen\CGCall.cpp:4198:0
#14 0x00007ff740abc90e clang::CodeGen::CodeGenFunction::EmitCall(class clang::QualType, class clang::CodeGen::CGCallee const &, class clang::CallExpr const *, class clang::CodeGen::ReturnValueSlot, class llvm::Value *) C:\llvm-project\clang\lib\CodeGen\CGExpr.cpp:5296:0
#15 0x00007ff740abd21c clang::CodeGen::CodeGenFunction::EmitCallExpr(class clang::CallExpr const *, class clang::CodeGen::ReturnValueSlot) C:\llvm-project\clang\lib\CodeGen\CGExpr.cpp:4890:0
#16 0x00007ff740e08b6b `anonymous namespace'::ScalarExprEmitter::VisitCallExpr C:\llvm-project\clang\lib\CodeGen\CGExprScalar.cpp:581:0
#17 0x00007ff740e05d6a clang::StmtVisitorBase<std::add_pointer,`anonymous namespace'::ScalarExprEmitter,llvm::Value *>::Visit C:\llvm-project\build\tools\clang\include\clang\AST\StmtNodes.inc:877:0
#18 0x00007ff740e06f79 `anonymous namespace'::ScalarExprEmitter::Visit C:\llvm-project\clang\lib\CodeGen\CGExprScalar.cpp:412:0
#19 0x00007ff740defc80 `anonymous namespace'::ScalarExprEmitter::EmitBinOps C:\llvm-project\clang\lib\CodeGen\CGExprScalar.cpp:3052:0
#20 0x00007ff740df0d9e `anonymous namespace'::ScalarExprEmitter::EmitCompare C:\llvm-project\clang\lib\CodeGen\CGExprScalar.cpp:4086:0
#21 0x00007ff740e0752b `anonymous namespace'::ScalarExprEmitter::VisitBinEQ C:\llvm-project\clang\lib\CodeGen\CGExprScalar.cpp:837:0
#22 0x00007ff740e04fe2 clang::StmtVisitorBase<std::add_pointer,`anonymous namespace'::ScalarExprEmitter,llvm::Value *>::Visit C:\llvm-project\clang\include\clang\AST\StmtVisitor.h:63:0
#23 0x00007ff740e06f79 `anonymous namespace'::ScalarExprEmitter::Visit C:\llvm-project\clang\lib\CodeGen\CGExprScalar.cpp:412:0
#24 0x00007ff740ddf258 clang::CodeGen::CodeGenFunction::EmitScalarExpr(class clang::Expr const *, bool) C:\llvm-project\clang\lib\CodeGen\CGExprScalar.cpp:4866:0
#25 0x00007ff740aa5af3 clang::CodeGen::CodeGenFunction::EvaluateExprAsBool(class clang::Expr const *) C:\llvm-project\clang\lib\CodeGen\CGExpr.cpp:182:0
#26 0x00007ff740a8bca8 clang::CodeGen::CodeGenFunction::EmitBranchOnBoolExpr(class clang::Expr const *, class llvm::BasicBlock *, class llvm::BasicBlock *, unsigned __int64, enum clang::Stmt::Likelihood) C:\llvm-project\clang\lib\CodeGen\CodeGenFunction.cpp:1846:0
#27 0x00007ff740d89830 clang::CodeGen::CodeGenFunction::EmitIfStmt(class clang::IfStmt const &) C:\llvm-project\clang\lib\CodeGen\CGStmt.cpp:782:0
#28 0x00007ff740d875bb clang::CodeGen::CodeGenFunction::EmitStmt(class clang::Stmt const *, class llvm::ArrayRef<class clang::Attr const *>) C:\llvm-project\clang\lib\CodeGen\CGStmt.cpp:148:0
#29 0x00007ff740d88b90 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(class clang::CompoundStmt const &, bool, class clang::CodeGen::AggValueSlot) C:\llvm-project\clang\lib\CodeGen\CGStmt.cpp:505:0
#30 0x00007ff740a84c42 clang::CodeGen::CodeGenFunction::EmitFunctionBody(class clang::Stmt const *) C:\llvm-project\clang\lib\CodeGen\CodeGenFunction.cpp:1210:0
#31 0x00007ff740a7d9a8 clang::CodeGen::CodeGenFunction::GenerateCode(class clang::GlobalDecl, class llvm::Function *, class clang::CodeGen::CGFunctionInfo const &) C:\llvm-project\clang\lib\CodeGen\CodeGenFunction.cpp:1420:0
#32 0x00007ff74066ff7d clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(class clang::GlobalDecl, class llvm::GlobalValue *) C:\llvm-project\clang\lib\CodeGen\CodeGenModule.cpp:5032:0
#33 0x00007ff74066fc64 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(class clang::GlobalDecl, class llvm::GlobalValue *) C:\llvm-project\clang\lib\CodeGen\CodeGenModule.cpp:3314:0
#34 0x00007ff7406745d4 clang::CodeGen::CodeGenModule::EmitDeferred(void) C:\llvm-project\clang\lib\CodeGen\CodeGenModule.cpp:2531:0
#35 0x00007ff74067461b clang::CodeGen::CodeGenModule::EmitDeferred(void) C:\llvm-project\clang\lib\CodeGen\CodeGenModule.cpp:2533:0
#36 0x00007ff74067461b clang::CodeGen::CodeGenModule::EmitDeferred(void) C:\llvm-project\clang\lib\CodeGen\CodeGenModule.cpp:2533:0
#37 0x00007ff74067461b clang::CodeGen::CodeGenModule::EmitDeferred(void) C:\llvm-project\clang\lib\CodeGen\CodeGenModule.cpp:2533:0
#38 0x00007ff74067461b clang::CodeGen::CodeGenModule::EmitDeferred(void) C:\llvm-project\clang\lib\CodeGen\CodeGenModule.cpp:2533:0
#39 0x00007ff74067461b clang::CodeGen::CodeGenModule::EmitDeferred(void) C:\llvm-project\clang\lib\CodeGen\CodeGenModule.cpp:2533:0
#40 0x00007ff74067461b clang::CodeGen::CodeGenModule::EmitDeferred(void) C:\llvm-project\clang\lib\CodeGen\CodeGenModule.cpp:2533:0
#41 0x00007ff740659dfa clang::CodeGen::CodeGenModule::Release(void) C:\llvm-project\clang\lib\CodeGen\CodeGenModule.cpp:506:0
#42 0x00007ff747ca3d5d `anonymous namespace'::CodeGeneratorImpl::HandleTranslationUnit C:\llvm-project\clang\lib\CodeGen\ModuleBuilder.cpp:275:0
#43 0x00007ff747c9bf98 clang::BackendConsumer::HandleTranslationUnit(class clang::ASTContext &) C:\llvm-project\clang\lib\CodeGen\CodeGenAction.cpp:306:0
#44 0x00007ff7448a1186 clang::ParseAST(class clang::Sema &, bool, bool) C:\llvm-project\clang\lib\Parse\ParseAST.cpp:178:0
#45 0x00007ff7414ebcdb clang::ASTFrontendAction::ExecuteAction(void) C:\llvm-project\clang\lib\Frontend\FrontendAction.cpp:1076:0
#46 0x00007ff747c8ed45 clang::CodeGenAction::ExecuteAction(void) C:\llvm-project\clang\lib\CodeGen\CodeGenAction.cpp:1107:0
#47 0x00007ff7414eb66c clang::FrontendAction::Execute(void) C:\llvm-project\clang\lib\Frontend\FrontendAction.cpp:971:0
#48 0x00007ff74145f2c4 clang::CompilerInstance::ExecuteAction(class clang::FrontendAction &) C:\llvm-project\clang\lib\Frontend\CompilerInstance.cpp:1030:0
#49 0x00007ff7416f2a96 clang::ExecuteCompilerInvocation(class clang::CompilerInstance *) C:\llvm-project\clang\lib\FrontendTool\ExecuteCompilerInvocation.cpp:261:0
#50 0x00007ff73ac8b622 cc1_main(class llvm::ArrayRef<char const *>, char const *, void *) C:\llvm-project\clang\tools\driver\cc1_main.cpp:246:0
#51 0x00007ff73ac74753 ExecuteCC1Tool C:\llvm-project\clang\tools\driver\driver.cpp:317:0
#52 0x00007ff741256256 <lambda_25c96514421f9d21a88a4b637eac86f0>::operator() C:\llvm-project\clang\lib\Driver\Job.cpp:407:0
#53 0x00007ff741254fa8 llvm::function_ref<(void)>::callback_fn<class <lambda_25c96514421f9d21a88a4b637eac86f0>>(__int64) C:\llvm-project\llvm\include\llvm\ADT\STLExtras.h:234:0
#54 0x00007ff73fcc42be llvm::function_ref<(void)>::operator()(void) const C:\llvm-project\llvm\include\llvm\ADT\STLExtras.h:256:0
#55 0x00007ff73fcd407f llvm::CrashRecoveryContext::RunSafely(class llvm::function_ref<(void)>) C:\llvm-project\llvm\lib\Support\CrashRecoveryContext.cpp:234:0
#56 0x00007ff741251db8 clang::driver::CC1Command::Execute(class llvm::ArrayRef<class llvm::Optional<class llvm::StringRef>>, class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char>> *, bool *) const C:\llvm-project\clang\lib\Driver\Job.cpp:407:0
#57 0x00007ff741174df0 clang::driver::Compilation::ExecuteCommand(class clang::driver::Command const &, class clang::driver::Command const *&) const C:\llvm-project\clang\lib\Driver\Compilation.cpp:196:0
#58 0x00007ff74117502a clang::driver::Compilation::ExecuteJobs(class clang::driver::JobList const &, class llvm::SmallVectorImpl<struct std::pair<int, class clang::driver::Command const *>> &) const C:\llvm-project\clang\lib\Driver\Compilation.cpp:249:0
#59 0x00007ff741113cb9 clang::driver::Driver::ExecuteCompilation(class clang::driver::Compilation &, class llvm::SmallVectorImpl<struct std::pair<int, class clang::driver::Command const *>> &) C:\llvm-project\clang\lib\Driver\Driver.cpp:1583:0
#60 0x00007ff73ac75c79 main C:\llvm-project\clang\tools\driver\driver.cpp:489:0
#61 0x00007ff7478926c9 invoke_main d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:79:0
#62 0x00007ff74789256e __scrt_common_main_seh d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0
#63 0x00007ff74789242e __scrt_common_main d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331:0
#64 0x00007ff747892759 mainCRTStartup d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17:0
#65 0x00007ff8b7a37034 (C:\WINDOWS\System32\KERNEL32.DLL+0x17034)
#66 0x00007ff8b8122651 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x52651)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 14.0.0 (https://github.com/llvm/llvm-project.git db5b7915959a45951c3e6a0d5cc61f0f4ddfe291)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\llvm-project\build\Debug\bin
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: r:\hello-154568.cpp
clang: note: diagnostic msg: r:\hello-154568.sh
clang: note: diagnostic msg: 

... I cannot attach those files, the server says we don't support that file type. Pasting the .sh below. The .cpp is too big to paste, let me know if you want me to email a copy. Pasting the input hello.cpp source file below.

#include <iostream>

int main() {
    std::cout << "Hello, world!\n";
    return 0;
}

# Crash reproducer for clang version 14.0.0 (https://github.com/llvm/llvm-project.git db5b7915959a45951c3e6a0d5cc61f0f4ddfe291)
# Driver args: "-S" "-emit-llvm" "-mllvm" "-opaque-pointers" "c:\\olivine\\test\\hello.cpp"
# Original command:  "C:\\llvm-project\\build\\Debug\\bin\\clang.exe" "-cc1" "-triple" "x86_64-pc-windows-msvc19.25.28610" "-emit-llvm" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "hello.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=none" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-mllvm" "-treat-scalable-fixed-error-as-warning" "-fcoverage-compilation-dir=R:\\" "-resource-dir" "C:\\llvm-project\\build\\Debug\\lib\\clang\\14.0.0" "-internal-isystem" "C:\\llvm-project\\build\\Debug\\lib\\clang\\14.0.0\\include" "-internal-isystem" "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.25.28610\\include" "-internal-isystem" "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.25.28610\\atlmfc\\include" "-internal-isystem" "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\ucrt" "-internal-isystem" "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\shared" "-internal-isystem" "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\um" "-internal-isystem" "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\winrt" "-fdeprecated-macro" "-fdebug-compilation-dir=R:\\" "-ferror-limit" "19" "-fno-use-cxa-atexit" "-fms-extensions" "-fms-compatibility" "-fms-compatibility-version=19.25.28610" "-std=c++14" "-fdelayed-template-parsing" "-fcxx-exceptions" "-fexceptions" "-mllvm" "-opaque-pointers" "-faddrsig" "-o" "hello.ll" "-x" "c++" "c:\\olivine\\test\\hello.cpp"
 "C:\\llvm-project\\build\\Debug\\bin\\clang.exe" "-cc1" "-triple" "x86_64-pc-windows-msvc19.25.28610" "-emit-llvm" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "hello.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=none" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-mllvm" "-treat-scalable-fixed-error-as-warning" "-fcoverage-compilation-dir=R:\\" "-fdeprecated-macro" "-fdebug-compilation-dir=R:\\" "-ferror-limit" "19" "-fno-use-cxa-atexit" "-fms-extensions" "-fms-compatibility" "-fms-compatibility-version=19.25.28610" "-std=c++14" "-fdelayed-template-parsing" "-fcxx-exceptions" "-fexceptions" "-mllvm" "-opaque-pointers" "-faddrsig" "-x" "c++" "hello-154568.cpp"
@nikic nikic changed the title Recent clang crashes trying to compile hello.cpp on Windows Recent clang crashes trying to compile hello.cpp on Windows with opaque pointers Jan 9, 2022
@nikic
Copy link
Contributor

nikic commented Jan 10, 2022

You can paste the expanded cpp file on gist.github.com.

@nikic
Copy link
Contributor

nikic commented Jan 10, 2022

I pushed a speculative fix at 7725331, maybe it will be sufficient.

@nikic
Copy link
Contributor

nikic commented Mar 3, 2022

Just want to check back here whether you're still seeing issues on Windows?

@russellw
Copy link
Author

russellw commented Mar 12, 2022 via email

@EugeneZelenko
Copy link
Contributor

@russellw: Could this issue be closed?

@russellw
Copy link
Author

russellw commented Mar 12, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants