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

ICE in clang::Sema::tryCaptureVariable #91633

Closed
Woebbeking opened this issue May 9, 2024 · 4 comments · Fixed by #93206
Closed

ICE in clang::Sema::tryCaptureVariable #91633

Woebbeking opened this issue May 9, 2024 · 4 comments · Fixed by #93206
Labels
c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@Woebbeking
Copy link

Hi,

clang-18 crashes for me in the attached testcase testcase.zip

0.      Program arguments: clang++ -O2 -std=c++20 -c testcase.cpp
1.      <eof> parser at end of file
2.      testcase.cpp:34:1: instantiating function definition 'findDetail<false, (lambda at testcase.cpp:62:36)>'
3.      testcase.cpp:37:23: instantiating function definition 'findDetail(const std::vector<int> &, (lambda at testcase.cpp:62:36))::(anonymous class)::operator()<Foo>'
 #0 0x00007f362f5d9a09 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib64/libLLVM.so.18.1+0x9d9a09)
 #1 0x00007f362f5d7430 llvm::sys::RunSignalHandlers() (/lib64/libLLVM.so.18.1+0x9d7430)
 #2 0x00007f362f512ce0 (/lib64/libLLVM.so.18.1+0x912ce0)
 #3 0x00007f362e441240 __restore_rt (/lib64/libc.so.6+0x41240)
 #4 0x00007f36377fdf24 clang::Sema::tryCaptureVariable(clang::ValueDecl*, clang::SourceLocation, clang::Sema::TryCaptureKind, clang::SourceLocation, bool, clang::QualType&, clang::QualType&, unsigned int const*) (/lib64/libclang-cpp.so.18.1+0x17fdf24)
 #5 0x00007f36377bdd8b clang::Sema::BuildDeclRefExpr(clang::ValueDecl*, clang::QualType, clang::ExprValueKind, clang::DeclarationNameInfo const&, clang::NestedNameSpecifierLoc, clang::NamedDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) (/lib64/libclang-cpp.so.18.1+0x17bdd8b)
 #6 0x00007f36377bdced clang::Sema::BuildDeclRefExpr(clang::ValueDecl*, clang::QualType, clang::ExprValueKind, clang::DeclarationNameInfo const&, clang::CXXScopeSpec const*, clang::NamedDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) (/lib64/libclang-cpp.so.18.1+0x17bdced)
 #7 0x00007f36377c2d81 clang::Sema::BuildDeclarationNameExpr(clang::CXXScopeSpec const&, clang::DeclarationNameInfo const&, clang::NamedDecl*, clang::NamedDecl*, clang::TemplateArgumentListInfo const*, bool) (/lib64/libclang-cpp.so.18.1+0x17c2d81)
 #8 0x00007f3637cdd15f (/lib64/libclang-cpp.so.18.1+0x1cdd15f)
 #9 0x00007f3637cd2414 (/lib64/libclang-cpp.so.18.1+0x1cd2414)
#10 0x00007f3637ccf191 (/lib64/libclang-cpp.so.18.1+0x1ccf191)
#11 0x00007f3637cd3aad (/lib64/libclang-cpp.so.18.1+0x1cd3aad)
#12 0x00007f3637cd6e4d (/lib64/libclang-cpp.so.18.1+0x1cd6e4d)
#13 0x00007f3637cc8f45 (/lib64/libclang-cpp.so.18.1+0x1cc8f45)
#14 0x00007f36375c5ae9 (/lib64/libclang-cpp.so.18.1+0x15c5ae9)
#15 0x00007f36375c423b (/lib64/libclang-cpp.so.18.1+0x15c423b)
#16 0x00007f36375be82a (/lib64/libclang-cpp.so.18.1+0x15be82a)
#17 0x00007f36375be098 clang::Sema::CheckConstraintSatisfaction(clang::NamedDecl const*, llvm::ArrayRef<clang::Expr const*>, llvm::SmallVectorImpl<clang::Expr*>&, clang::MultiLevelTemplateArgumentList const&, clang::SourceRange, clang::ConstraintSatisfaction&) (/lib64/libclang-cpp.so.18.1+0x15be098)
#18 0x00007f36375c132f clang::Sema::CheckInstantiatedFunctionTemplateConstraints(clang::SourceLocation, clang::FunctionDecl*, llvm::ArrayRef<clang::TemplateArgument>, clang::ConstraintSatisfaction&) (/lib64/libclang-cpp.so.18.1+0x15c132f)
#19 0x00007f3637c53859 clang::Sema::FinishTemplateArgumentDeduction(clang::FunctionTemplateDecl*, llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, unsigned int, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, llvm::SmallVectorImpl<clang::Sema::OriginalCallArg> const*, bool, llvm::function_ref<bool ()>) (/lib64/libclang-cpp.so.18.1+0x1c53859)
#20 0x00007f3637c5543b clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>) (/lib64/libclang-cpp.so.18.1+0x1c5543b)
#21 0x00007f3637afedf7 clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamOrder, bool) (/lib64/libclang-cpp.so.18.1+0x1afedf7)
#22 0x00007f3637b06088 clang::Sema::AddArgumentDependentLookupCandidates(clang::DeclarationName, clang::SourceLocation, llvm::ArrayRef<clang::Expr*>, clang::TemplateArgumentListInfo*, clang::OverloadCandidateSet&, bool) (/lib64/libclang-cpp.so.18.1+0x1b06088)
#23 0x00007f3637b154ff clang::Sema::LookupOverloadedBinOp(clang::OverloadCandidateSet&, clang::OverloadedOperatorKind, clang::UnresolvedSetImpl const&, llvm::ArrayRef<clang::Expr*>, bool) (/lib64/libclang-cpp.so.18.1+0x1b154ff)
#24 0x00007f3637b15875 clang::Sema::CreateOverloadedBinOp(clang::SourceLocation, clang::BinaryOperatorKind, clang::UnresolvedSetImpl const&, clang::Expr*, clang::Expr*, bool, bool, clang::FunctionDecl*) (/lib64/libclang-cpp.so.18.1+0x1b15875)
#25 0x00007f36377f398d (/lib64/libclang-cpp.so.18.1+0x17f398d)
#26 0x00007f36377f3409 clang::Sema::BuildBinOp(clang::Scope*, clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) (/lib64/libclang-cpp.so.18.1+0x17f3409)
#27 0x00007f3637cd3c6b (/lib64/libclang-cpp.so.18.1+0x1cd3c6b)
#28 0x00007f3637cec278 (/lib64/libclang-cpp.so.18.1+0x1cec278)
#29 0x00007f3637cea103 (/lib64/libclang-cpp.so.18.1+0x1cea103)
#30 0x00007f3637cd4e51 (/lib64/libclang-cpp.so.18.1+0x1cd4e51)
#31 0x00007f3637cc1f53 clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/lib64/libclang-cpp.so.18.1+0x1cc1f53)
#32 0x00007f3637d0d927 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/lib64/libclang-cpp.so.18.1+0x1d0d927)
#33 0x00007f3637d10677 clang::Sema::PerformPendingInstantiations(bool) (/lib64/libclang-cpp.so.18.1+0x1d10677)
#34 0x00007f3637d0da63 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/lib64/libclang-cpp.so.18.1+0x1d0da63)
#35 0x00007f3637d10677 clang::Sema::PerformPendingInstantiations(bool) (/lib64/libclang-cpp.so.18.1+0x1d10677)
#36 0x00007f363744af37 clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind) (/lib64/libclang-cpp.so.18.1+0x144af37)
#37 0x00007f363744b66f clang::Sema::ActOnEndOfTranslationUnit() (/lib64/libclang-cpp.so.18.1+0x144b66f)
#38 0x00007f3636b690bd clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/lib64/libclang-cpp.so.18.1+0xb690bd)
#39 0x00007f3636a8ec6c clang::ParseAST(clang::Sema&, bool, bool) (/lib64/libclang-cpp.so.18.1+0xa8ec6c)
#40 0x00007f3638d2a756 clang::FrontendAction::Execute() (/lib64/libclang-cpp.so.18.1+0x2d2a756)
#41 0x00007f3638c9d1b4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib64/libclang-cpp.so.18.1+0x2c9d1b4)
#42 0x00007f3638da5e36 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib64/libclang-cpp.so.18.1+0x2da5e36)
#43 0x000055b776841660 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang-18+0x12660)
#44 0x000055b77683e3a8 (/usr/bin/clang-18+0xf3a8)
#45 0x00007f3638916389 (/lib64/libclang-cpp.so.18.1+0x2916389)
#46 0x00007f362f512a6e llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/lib64/libLLVM.so.18.1+0x912a6e)
#47 0x00007f36389160e0 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/lib64/libclang-cpp.so.18.1+0x29160e0)
#48 0x00007f36388ddeac clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/lib64/libclang-cpp.so.18.1+0x28ddeac)
#49 0x00007f36388de0ee clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/lib64/libclang-cpp.so.18.1+0x28de0ee)
#50 0x00007f36388fa74c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/lib64/libclang-cpp.so.18.1+0x28fa74c)
#51 0x000055b77683dc3d clang_main(int, char**, llvm::ToolContext const&) (/usr/bin/clang-18+0xec3d)
#52 0x000055b77684a6e9 main (/usr/bin/clang-18+0x1b6e9)
#53 0x00007f362e42a1f0 __libc_start_call_main /usr/src/debug/glibc-2.39/csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#54 0x00007f362e42a2b9 call_init /usr/src/debug/glibc-2.39/csu/../csu/libc-start.c:128:20
#55 0x00007f362e42a2b9 __libc_start_main@GLIBC_2.2.5 /usr/src/debug/glibc-2.39/csu/../csu/libc-start.c:347:5
#56 0x000055b77683ab25 _start (/usr/bin/clang-18+0xbb25)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 18.1.4
Target: x86_64-suse-linux
Thread model: posix
InstalledDir: /usr/bin
clang++: note: diagnostic msg: 

Maybe this is a duplicate of #90669 clang-17 works fine.

Cheers,
André

@github-actions github-actions bot added the clang Clang issues not falling into any other category label May 9, 2024
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] and removed clang Clang issues not falling into any other category labels May 9, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented May 9, 2024

@llvm/issue-subscribers-clang-frontend

Author: None (Woebbeking)

Hi,

clang-18 crashes for me in the attached testcase testcase.zip

0.      Program arguments: clang++ -O2 -std=c++20 -c testcase.cpp
1.      &lt;eof&gt; parser at end of file
2.      testcase.cpp:34:1: instantiating function definition 'findDetail&lt;false, (lambda at testcase.cpp:62:36)&gt;'
3.      testcase.cpp:37:23: instantiating function definition 'findDetail(const std::vector&lt;int&gt; &amp;, (lambda at testcase.cpp:62:36))::(anonymous class)::operator()&lt;Foo&gt;'
 #<!-- -->0 0x00007f362f5d9a09 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/lib64/libLLVM.so.18.1+0x9d9a09)
 #<!-- -->1 0x00007f362f5d7430 llvm::sys::RunSignalHandlers() (/lib64/libLLVM.so.18.1+0x9d7430)
 #<!-- -->2 0x00007f362f512ce0 (/lib64/libLLVM.so.18.1+0x912ce0)
 #<!-- -->3 0x00007f362e441240 __restore_rt (/lib64/libc.so.6+0x41240)
 #<!-- -->4 0x00007f36377fdf24 clang::Sema::tryCaptureVariable(clang::ValueDecl*, clang::SourceLocation, clang::Sema::TryCaptureKind, clang::SourceLocation, bool, clang::QualType&amp;, clang::QualType&amp;, unsigned int const*) (/lib64/libclang-cpp.so.18.1+0x17fdf24)
 #<!-- -->5 0x00007f36377bdd8b clang::Sema::BuildDeclRefExpr(clang::ValueDecl*, clang::QualType, clang::ExprValueKind, clang::DeclarationNameInfo const&amp;, clang::NestedNameSpecifierLoc, clang::NamedDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) (/lib64/libclang-cpp.so.18.1+0x17bdd8b)
 #<!-- -->6 0x00007f36377bdced clang::Sema::BuildDeclRefExpr(clang::ValueDecl*, clang::QualType, clang::ExprValueKind, clang::DeclarationNameInfo const&amp;, clang::CXXScopeSpec const*, clang::NamedDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) (/lib64/libclang-cpp.so.18.1+0x17bdced)
 #<!-- -->7 0x00007f36377c2d81 clang::Sema::BuildDeclarationNameExpr(clang::CXXScopeSpec const&amp;, clang::DeclarationNameInfo const&amp;, clang::NamedDecl*, clang::NamedDecl*, clang::TemplateArgumentListInfo const*, bool) (/lib64/libclang-cpp.so.18.1+0x17c2d81)
 #<!-- -->8 0x00007f3637cdd15f (/lib64/libclang-cpp.so.18.1+0x1cdd15f)
 #<!-- -->9 0x00007f3637cd2414 (/lib64/libclang-cpp.so.18.1+0x1cd2414)
#<!-- -->10 0x00007f3637ccf191 (/lib64/libclang-cpp.so.18.1+0x1ccf191)
#<!-- -->11 0x00007f3637cd3aad (/lib64/libclang-cpp.so.18.1+0x1cd3aad)
#<!-- -->12 0x00007f3637cd6e4d (/lib64/libclang-cpp.so.18.1+0x1cd6e4d)
#<!-- -->13 0x00007f3637cc8f45 (/lib64/libclang-cpp.so.18.1+0x1cc8f45)
#<!-- -->14 0x00007f36375c5ae9 (/lib64/libclang-cpp.so.18.1+0x15c5ae9)
#<!-- -->15 0x00007f36375c423b (/lib64/libclang-cpp.so.18.1+0x15c423b)
#<!-- -->16 0x00007f36375be82a (/lib64/libclang-cpp.so.18.1+0x15be82a)
#<!-- -->17 0x00007f36375be098 clang::Sema::CheckConstraintSatisfaction(clang::NamedDecl const*, llvm::ArrayRef&lt;clang::Expr const*&gt;, llvm::SmallVectorImpl&lt;clang::Expr*&gt;&amp;, clang::MultiLevelTemplateArgumentList const&amp;, clang::SourceRange, clang::ConstraintSatisfaction&amp;) (/lib64/libclang-cpp.so.18.1+0x15be098)
#<!-- -->18 0x00007f36375c132f clang::Sema::CheckInstantiatedFunctionTemplateConstraints(clang::SourceLocation, clang::FunctionDecl*, llvm::ArrayRef&lt;clang::TemplateArgument&gt;, clang::ConstraintSatisfaction&amp;) (/lib64/libclang-cpp.so.18.1+0x15c132f)
#<!-- -->19 0x00007f3637c53859 clang::Sema::FinishTemplateArgumentDeduction(clang::FunctionTemplateDecl*, llvm::SmallVectorImpl&lt;clang::DeducedTemplateArgument&gt;&amp;, unsigned int, clang::FunctionDecl*&amp;, clang::sema::TemplateDeductionInfo&amp;, llvm::SmallVectorImpl&lt;clang::Sema::OriginalCallArg&gt; const*, bool, llvm::function_ref&lt;bool ()&gt;) (/lib64/libclang-cpp.so.18.1+0x1c53859)
#<!-- -->20 0x00007f3637c5543b clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef&lt;clang::Expr*&gt;, clang::FunctionDecl*&amp;, clang::sema::TemplateDeductionInfo&amp;, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref&lt;bool (llvm::ArrayRef&lt;clang::QualType&gt;)&gt;) (/lib64/libclang-cpp.so.18.1+0x1c5543b)
#<!-- -->21 0x00007f3637afedf7 clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef&lt;clang::Expr*&gt;, clang::OverloadCandidateSet&amp;, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamOrder, bool) (/lib64/libclang-cpp.so.18.1+0x1afedf7)
#<!-- -->22 0x00007f3637b06088 clang::Sema::AddArgumentDependentLookupCandidates(clang::DeclarationName, clang::SourceLocation, llvm::ArrayRef&lt;clang::Expr*&gt;, clang::TemplateArgumentListInfo*, clang::OverloadCandidateSet&amp;, bool) (/lib64/libclang-cpp.so.18.1+0x1b06088)
#<!-- -->23 0x00007f3637b154ff clang::Sema::LookupOverloadedBinOp(clang::OverloadCandidateSet&amp;, clang::OverloadedOperatorKind, clang::UnresolvedSetImpl const&amp;, llvm::ArrayRef&lt;clang::Expr*&gt;, bool) (/lib64/libclang-cpp.so.18.1+0x1b154ff)
#<!-- -->24 0x00007f3637b15875 clang::Sema::CreateOverloadedBinOp(clang::SourceLocation, clang::BinaryOperatorKind, clang::UnresolvedSetImpl const&amp;, clang::Expr*, clang::Expr*, bool, bool, clang::FunctionDecl*) (/lib64/libclang-cpp.so.18.1+0x1b15875)
#<!-- -->25 0x00007f36377f398d (/lib64/libclang-cpp.so.18.1+0x17f398d)
#<!-- -->26 0x00007f36377f3409 clang::Sema::BuildBinOp(clang::Scope*, clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) (/lib64/libclang-cpp.so.18.1+0x17f3409)
#<!-- -->27 0x00007f3637cd3c6b (/lib64/libclang-cpp.so.18.1+0x1cd3c6b)
#<!-- -->28 0x00007f3637cec278 (/lib64/libclang-cpp.so.18.1+0x1cec278)
#<!-- -->29 0x00007f3637cea103 (/lib64/libclang-cpp.so.18.1+0x1cea103)
#<!-- -->30 0x00007f3637cd4e51 (/lib64/libclang-cpp.so.18.1+0x1cd4e51)
#<!-- -->31 0x00007f3637cc1f53 clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&amp;) (/lib64/libclang-cpp.so.18.1+0x1cc1f53)
#<!-- -->32 0x00007f3637d0d927 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/lib64/libclang-cpp.so.18.1+0x1d0d927)
#<!-- -->33 0x00007f3637d10677 clang::Sema::PerformPendingInstantiations(bool) (/lib64/libclang-cpp.so.18.1+0x1d10677)
#<!-- -->34 0x00007f3637d0da63 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/lib64/libclang-cpp.so.18.1+0x1d0da63)
#<!-- -->35 0x00007f3637d10677 clang::Sema::PerformPendingInstantiations(bool) (/lib64/libclang-cpp.so.18.1+0x1d10677)
#<!-- -->36 0x00007f363744af37 clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind) (/lib64/libclang-cpp.so.18.1+0x144af37)
#<!-- -->37 0x00007f363744b66f clang::Sema::ActOnEndOfTranslationUnit() (/lib64/libclang-cpp.so.18.1+0x144b66f)
#<!-- -->38 0x00007f3636b690bd clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&lt;clang::DeclGroupRef&gt;&amp;, clang::Sema::ModuleImportState&amp;) (/lib64/libclang-cpp.so.18.1+0xb690bd)
#<!-- -->39 0x00007f3636a8ec6c clang::ParseAST(clang::Sema&amp;, bool, bool) (/lib64/libclang-cpp.so.18.1+0xa8ec6c)
#<!-- -->40 0x00007f3638d2a756 clang::FrontendAction::Execute() (/lib64/libclang-cpp.so.18.1+0x2d2a756)
#<!-- -->41 0x00007f3638c9d1b4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/lib64/libclang-cpp.so.18.1+0x2c9d1b4)
#<!-- -->42 0x00007f3638da5e36 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib64/libclang-cpp.so.18.1+0x2da5e36)
#<!-- -->43 0x000055b776841660 cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/usr/bin/clang-18+0x12660)
#<!-- -->44 0x000055b77683e3a8 (/usr/bin/clang-18+0xf3a8)
#<!-- -->45 0x00007f3638916389 (/lib64/libclang-cpp.so.18.1+0x2916389)
#<!-- -->46 0x00007f362f512a6e llvm::CrashRecoveryContext::RunSafely(llvm::function_ref&lt;void ()&gt;) (/lib64/libLLVM.so.18.1+0x912a6e)
#<!-- -->47 0x00007f36389160e0 clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const (/lib64/libclang-cpp.so.18.1+0x29160e0)
#<!-- -->48 0x00007f36388ddeac clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&amp;, clang::driver::Command const*&amp;, bool) const (/lib64/libclang-cpp.so.18.1+0x28ddeac)
#<!-- -->49 0x00007f36388de0ee clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;, bool) const (/lib64/libclang-cpp.so.18.1+0x28de0ee)
#<!-- -->50 0x00007f36388fa74c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;) (/lib64/libclang-cpp.so.18.1+0x28fa74c)
#<!-- -->51 0x000055b77683dc3d clang_main(int, char**, llvm::ToolContext const&amp;) (/usr/bin/clang-18+0xec3d)
#<!-- -->52 0x000055b77684a6e9 main (/usr/bin/clang-18+0x1b6e9)
#<!-- -->53 0x00007f362e42a1f0 __libc_start_call_main /usr/src/debug/glibc-2.39/csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#<!-- -->54 0x00007f362e42a2b9 call_init /usr/src/debug/glibc-2.39/csu/../csu/libc-start.c:128:20
#<!-- -->55 0x00007f362e42a2b9 __libc_start_main@<!-- -->GLIBC_2.2.5 /usr/src/debug/glibc-2.39/csu/../csu/libc-start.c:347:5
#<!-- -->56 0x000055b77683ab25 _start (/usr/bin/clang-18+0xbb25)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 18.1.4
Target: x86_64-suse-linux
Thread model: posix
InstalledDir: /usr/bin
clang++: note: diagnostic msg: 

Maybe this is a duplicate of #90669 clang-17 works fine.

Cheers,
André

@shafik shafik added the needs-reduction Large reproducer that should be reduced into a simpler form label May 9, 2024
@shafik
Copy link
Collaborator

shafik commented May 9, 2024

We have a number of these crashes that are similar but not exactly identical.

@Endilll
Copy link
Contributor

Endilll commented May 10, 2024

Confirmed on 19.0: https://godbolt.org/z/17Yvd4cbe
Reduced by me and C-Reduce:

struct __normal_iterator {};

template <typename _Iterator>
void operator==(_Iterator __lhs, _Iterator)
  requires requires { __lhs; };

__normal_iterator finder();

template <typename >
void findDetail() {
  auto makeResult = [&](auto foo) -> void {
    finder() != foo;
  };
  makeResult(__normal_iterator{});
}

void find() {
  findDetail<void>();
}

Clang 19.0 crash:

clang++: /root/llvm-project/llvm/include/llvm/ADT/SmallVector.h:304:
T& llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::operator[](llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::size_type) [with T = clang::sema::FunctionScopeInfo*; <template-parameter-1-2> = void; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::reference = clang::sema::FunctionScopeInfo*&; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::size_type = long unsigned int]:
Assertion `idx < size()' failed.

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: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 <source>
1.	<eof> parser at end of file
2.	<source>:10:6: instantiating function definition 'findDetail<void>'
3.	<source>:11:21: instantiating function definition 'findDetail()::(anonymous class)::operator()<__normal_iterator>'
 #0 0x000000000398f9d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x398f9d8)
 #1 0x000000000398d6bc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x398d6bc)
 #2 0x00000000038de728 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x0000735435a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x0000735435a969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x0000735435a42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x0000735435a287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x0000735435a2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x0000735435a39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x0000000006833a58 clang::Sema::tryCaptureVariable(clang::ValueDecl*, clang::SourceLocation, clang::Sema::TryCaptureKind, clang::SourceLocation, bool, clang::QualType&, clang::QualType&, unsigned int const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6833a58)
#10 0x0000000006860e86 clang::Sema::BuildDeclRefExpr(clang::ValueDecl*, clang::QualType, clang::ExprValueKind, clang::DeclarationNameInfo const&, clang::NestedNameSpecifierLoc, clang::NamedDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6860e86)
#11 0x00000000068616df clang::Sema::BuildDeclRefExpr(clang::ValueDecl*, clang::QualType, clang::ExprValueKind, clang::DeclarationNameInfo const&, clang::CXXScopeSpec const*, clang::NamedDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x68616df)
#12 0x0000000006867e24 clang::Sema::BuildDeclarationNameExpr(clang::CXXScopeSpec const&, clang::DeclarationNameInfo const&, clang::NamedDecl*, clang::NamedDecl*, clang::TemplateArgumentListInfo const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6867e24)
#13 0x0000000006eae332 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformDeclRefExpr(clang::DeclRefExpr*) SemaTemplateInstantiate.cpp:0:0
#14 0x0000000006eae53b (anonymous namespace)::TemplateInstantiator::TransformDeclRefExpr(clang::DeclRefExpr*) SemaTemplateInstantiate.cpp:0:0
#15 0x0000000006e88614 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#16 0x0000000006eb48ce clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformRequiresExpr(clang::RequiresExpr*) SemaTemplateInstantiate.cpp:0:0
#17 0x0000000006eb66fe (anonymous namespace)::TemplateInstantiator::TransformRequiresExpr(clang::RequiresExpr*) SemaTemplateInstantiate.cpp:0:0
#18 0x0000000006e88a19 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#19 0x0000000006ebf604 clang::Sema::SubstConstraintExpr(clang::Expr*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ebf604)
#20 0x00000000065748c3 calculateConstraintSatisfaction(clang::Sema&, clang::NamedDecl const*, clang::SourceLocation, clang::MultiLevelTemplateArgumentList const&, clang::Expr const*, clang::ConstraintSatisfaction&)::'lambda'(clang::Expr const*)::operator()(clang::Expr const*) const SemaConcept.cpp:0:0
#21 0x000000000657617b clang::ActionResult<clang::Expr*, true> calculateConstraintSatisfaction<calculateConstraintSatisfaction(clang::Sema&, clang::NamedDecl const*, clang::SourceLocation, clang::MultiLevelTemplateArgumentList const&, clang::Expr const*, clang::ConstraintSatisfaction&)::'lambda'(clang::Expr const*)>(clang::Sema&, clang::Expr const*, clang::ConstraintSatisfaction&, calculateConstraintSatisfaction(clang::Sema&, clang::NamedDecl const*, clang::SourceLocation, clang::MultiLevelTemplateArgumentList const&, clang::Expr const*, clang::ConstraintSatisfaction&)::'lambda'(clang::Expr const*)&&) SemaConcept.cpp:0:0
#22 0x0000000006576ae2 CheckConstraintSatisfaction(clang::Sema&, clang::NamedDecl const*, llvm::ArrayRef<clang::Expr const*>, llvm::SmallVectorImpl<clang::Expr*>&, clang::MultiLevelTemplateArgumentList const&, clang::SourceRange, clang::ConstraintSatisfaction&) SemaConcept.cpp:0:0
#23 0x000000000657711a clang::Sema::CheckConstraintSatisfaction(clang::NamedDecl const*, llvm::ArrayRef<clang::Expr const*>, llvm::SmallVectorImpl<clang::Expr*>&, clang::MultiLevelTemplateArgumentList const&, clang::SourceRange, clang::ConstraintSatisfaction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x657711a)
#24 0x00000000065781db clang::Sema::CheckInstantiatedFunctionTemplateConstraints(clang::SourceLocation, clang::FunctionDecl*, llvm::ArrayRef<clang::TemplateArgument>, clang::ConstraintSatisfaction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65781db)
#25 0x0000000006e46797 clang::Sema::FinishTemplateArgumentDeduction(clang::FunctionTemplateDecl*, llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, unsigned int, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, llvm::SmallVectorImpl<clang::Sema::OriginalCallArg> const*, bool, llvm::function_ref<bool ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e46797)
#26 0x0000000006e4801a void llvm::function_ref<void ()>::callback_fn<clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>)::'lambda1'()>(long) SemaTemplateDeduction.cpp:0:0
#27 0x0000000006410531 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6410531)
#28 0x0000000006e52892 clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e52892)
#29 0x0000000006c31308 clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamOrder, bool) (.constprop.1) SemaOverload.cpp:0:0
#30 0x0000000006c316fd clang::Sema::AddNonMemberOperatorCandidates(clang::UnresolvedSetImpl const&, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, clang::TemplateArgumentListInfo*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c316fd)
#31 0x0000000006c3435c clang::Sema::LookupOverloadedBinOp(clang::OverloadCandidateSet&, clang::OverloadedOperatorKind, clang::UnresolvedSetImpl const&, llvm::ArrayRef<clang::Expr*>, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c3435c)
#32 0x0000000006c40248 clang::Sema::CreateOverloadedBinOp(clang::SourceLocation, clang::BinaryOperatorKind, clang::UnresolvedSetImpl const&, clang::Expr*, clang::Expr*, bool, bool, clang::FunctionDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c40248)
#33 0x0000000006e72c4a clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::RebuildCXXOperatorCallExpr(clang::OverloadedOperatorKind, clang::SourceLocation, clang::SourceLocation, bool, clang::UnresolvedSetImpl const&, clang::Expr*, clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#34 0x0000000006eba2db clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCXXOperatorCallExpr(clang::CXXOperatorCallExpr*) SemaTemplateInstantiate.cpp:0:0
#35 0x0000000006e8853b clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#36 0x0000000006ec405f clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*, clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::StmtDiscardKind) SemaTemplateInstantiate.cpp:0:0
#37 0x0000000006ec4e34 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) SemaTemplateInstantiate.cpp:0:0
#38 0x0000000006ecc23a clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ecc23a)
#39 0x0000000006f23508 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f23508)
#40 0x0000000006f2183f clang::Sema::PerformPendingInstantiations(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f2183f)
#41 0x0000000006f22fec clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f22fec)
#42 0x0000000006f2183f clang::Sema::PerformPendingInstantiations(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f2183f)
#43 0x0000000006432cbf clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind) (.part.0) Sema.cpp:0:0
#44 0x00000000064334aa clang::Sema::ActOnEndOfTranslationUnit() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64334aa)
#45 0x00000000062ae44a clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x62ae44a)
#46 0x00000000062a1e2a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x62a1e2a)
#47 0x000000000425c1e8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x425c1e8)
#48 0x00000000044de9f9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44de9f9)
#49 0x00000000044660de clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44660de)
#50 0x00000000045c571e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45c571e)
#51 0x0000000000c5217c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc5217c)
#52 0x0000000000c4b4da ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#53 0x000000000429f3b9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#54 0x00000000038debd4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38debd4)
#55 0x000000000429f9af clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#56 0x0000000004265aa5 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4265aa5)
#57 0x000000000426650d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x426650d)
#58 0x000000000426e205 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x426e205)
#59 0x0000000000c4f685 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc4f685)
#60 0x0000000000b30bf4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb30bf4)
#61 0x0000735435a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#62 0x0000735435a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#63 0x0000000000c4af8e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc4af8e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134

@Endilll Endilll added confirmed Verified by a second party c++20 and removed needs-reduction Large reproducer that should be reduced into a simpler form labels May 10, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented May 10, 2024

@llvm/issue-subscribers-c-20

Author: None (Woebbeking)

Hi,

clang-18 crashes for me in the attached testcase testcase.zip

0.      Program arguments: clang++ -O2 -std=c++20 -c testcase.cpp
1.      &lt;eof&gt; parser at end of file
2.      testcase.cpp:34:1: instantiating function definition 'findDetail&lt;false, (lambda at testcase.cpp:62:36)&gt;'
3.      testcase.cpp:37:23: instantiating function definition 'findDetail(const std::vector&lt;int&gt; &amp;, (lambda at testcase.cpp:62:36))::(anonymous class)::operator()&lt;Foo&gt;'
 #<!-- -->0 0x00007f362f5d9a09 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/lib64/libLLVM.so.18.1+0x9d9a09)
 #<!-- -->1 0x00007f362f5d7430 llvm::sys::RunSignalHandlers() (/lib64/libLLVM.so.18.1+0x9d7430)
 #<!-- -->2 0x00007f362f512ce0 (/lib64/libLLVM.so.18.1+0x912ce0)
 #<!-- -->3 0x00007f362e441240 __restore_rt (/lib64/libc.so.6+0x41240)
 #<!-- -->4 0x00007f36377fdf24 clang::Sema::tryCaptureVariable(clang::ValueDecl*, clang::SourceLocation, clang::Sema::TryCaptureKind, clang::SourceLocation, bool, clang::QualType&amp;, clang::QualType&amp;, unsigned int const*) (/lib64/libclang-cpp.so.18.1+0x17fdf24)
 #<!-- -->5 0x00007f36377bdd8b clang::Sema::BuildDeclRefExpr(clang::ValueDecl*, clang::QualType, clang::ExprValueKind, clang::DeclarationNameInfo const&amp;, clang::NestedNameSpecifierLoc, clang::NamedDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) (/lib64/libclang-cpp.so.18.1+0x17bdd8b)
 #<!-- -->6 0x00007f36377bdced clang::Sema::BuildDeclRefExpr(clang::ValueDecl*, clang::QualType, clang::ExprValueKind, clang::DeclarationNameInfo const&amp;, clang::CXXScopeSpec const*, clang::NamedDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) (/lib64/libclang-cpp.so.18.1+0x17bdced)
 #<!-- -->7 0x00007f36377c2d81 clang::Sema::BuildDeclarationNameExpr(clang::CXXScopeSpec const&amp;, clang::DeclarationNameInfo const&amp;, clang::NamedDecl*, clang::NamedDecl*, clang::TemplateArgumentListInfo const*, bool) (/lib64/libclang-cpp.so.18.1+0x17c2d81)
 #<!-- -->8 0x00007f3637cdd15f (/lib64/libclang-cpp.so.18.1+0x1cdd15f)
 #<!-- -->9 0x00007f3637cd2414 (/lib64/libclang-cpp.so.18.1+0x1cd2414)
#<!-- -->10 0x00007f3637ccf191 (/lib64/libclang-cpp.so.18.1+0x1ccf191)
#<!-- -->11 0x00007f3637cd3aad (/lib64/libclang-cpp.so.18.1+0x1cd3aad)
#<!-- -->12 0x00007f3637cd6e4d (/lib64/libclang-cpp.so.18.1+0x1cd6e4d)
#<!-- -->13 0x00007f3637cc8f45 (/lib64/libclang-cpp.so.18.1+0x1cc8f45)
#<!-- -->14 0x00007f36375c5ae9 (/lib64/libclang-cpp.so.18.1+0x15c5ae9)
#<!-- -->15 0x00007f36375c423b (/lib64/libclang-cpp.so.18.1+0x15c423b)
#<!-- -->16 0x00007f36375be82a (/lib64/libclang-cpp.so.18.1+0x15be82a)
#<!-- -->17 0x00007f36375be098 clang::Sema::CheckConstraintSatisfaction(clang::NamedDecl const*, llvm::ArrayRef&lt;clang::Expr const*&gt;, llvm::SmallVectorImpl&lt;clang::Expr*&gt;&amp;, clang::MultiLevelTemplateArgumentList const&amp;, clang::SourceRange, clang::ConstraintSatisfaction&amp;) (/lib64/libclang-cpp.so.18.1+0x15be098)
#<!-- -->18 0x00007f36375c132f clang::Sema::CheckInstantiatedFunctionTemplateConstraints(clang::SourceLocation, clang::FunctionDecl*, llvm::ArrayRef&lt;clang::TemplateArgument&gt;, clang::ConstraintSatisfaction&amp;) (/lib64/libclang-cpp.so.18.1+0x15c132f)
#<!-- -->19 0x00007f3637c53859 clang::Sema::FinishTemplateArgumentDeduction(clang::FunctionTemplateDecl*, llvm::SmallVectorImpl&lt;clang::DeducedTemplateArgument&gt;&amp;, unsigned int, clang::FunctionDecl*&amp;, clang::sema::TemplateDeductionInfo&amp;, llvm::SmallVectorImpl&lt;clang::Sema::OriginalCallArg&gt; const*, bool, llvm::function_ref&lt;bool ()&gt;) (/lib64/libclang-cpp.so.18.1+0x1c53859)
#<!-- -->20 0x00007f3637c5543b clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef&lt;clang::Expr*&gt;, clang::FunctionDecl*&amp;, clang::sema::TemplateDeductionInfo&amp;, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref&lt;bool (llvm::ArrayRef&lt;clang::QualType&gt;)&gt;) (/lib64/libclang-cpp.so.18.1+0x1c5543b)
#<!-- -->21 0x00007f3637afedf7 clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef&lt;clang::Expr*&gt;, clang::OverloadCandidateSet&amp;, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamOrder, bool) (/lib64/libclang-cpp.so.18.1+0x1afedf7)
#<!-- -->22 0x00007f3637b06088 clang::Sema::AddArgumentDependentLookupCandidates(clang::DeclarationName, clang::SourceLocation, llvm::ArrayRef&lt;clang::Expr*&gt;, clang::TemplateArgumentListInfo*, clang::OverloadCandidateSet&amp;, bool) (/lib64/libclang-cpp.so.18.1+0x1b06088)
#<!-- -->23 0x00007f3637b154ff clang::Sema::LookupOverloadedBinOp(clang::OverloadCandidateSet&amp;, clang::OverloadedOperatorKind, clang::UnresolvedSetImpl const&amp;, llvm::ArrayRef&lt;clang::Expr*&gt;, bool) (/lib64/libclang-cpp.so.18.1+0x1b154ff)
#<!-- -->24 0x00007f3637b15875 clang::Sema::CreateOverloadedBinOp(clang::SourceLocation, clang::BinaryOperatorKind, clang::UnresolvedSetImpl const&amp;, clang::Expr*, clang::Expr*, bool, bool, clang::FunctionDecl*) (/lib64/libclang-cpp.so.18.1+0x1b15875)
#<!-- -->25 0x00007f36377f398d (/lib64/libclang-cpp.so.18.1+0x17f398d)
#<!-- -->26 0x00007f36377f3409 clang::Sema::BuildBinOp(clang::Scope*, clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) (/lib64/libclang-cpp.so.18.1+0x17f3409)
#<!-- -->27 0x00007f3637cd3c6b (/lib64/libclang-cpp.so.18.1+0x1cd3c6b)
#<!-- -->28 0x00007f3637cec278 (/lib64/libclang-cpp.so.18.1+0x1cec278)
#<!-- -->29 0x00007f3637cea103 (/lib64/libclang-cpp.so.18.1+0x1cea103)
#<!-- -->30 0x00007f3637cd4e51 (/lib64/libclang-cpp.so.18.1+0x1cd4e51)
#<!-- -->31 0x00007f3637cc1f53 clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&amp;) (/lib64/libclang-cpp.so.18.1+0x1cc1f53)
#<!-- -->32 0x00007f3637d0d927 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/lib64/libclang-cpp.so.18.1+0x1d0d927)
#<!-- -->33 0x00007f3637d10677 clang::Sema::PerformPendingInstantiations(bool) (/lib64/libclang-cpp.so.18.1+0x1d10677)
#<!-- -->34 0x00007f3637d0da63 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/lib64/libclang-cpp.so.18.1+0x1d0da63)
#<!-- -->35 0x00007f3637d10677 clang::Sema::PerformPendingInstantiations(bool) (/lib64/libclang-cpp.so.18.1+0x1d10677)
#<!-- -->36 0x00007f363744af37 clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind) (/lib64/libclang-cpp.so.18.1+0x144af37)
#<!-- -->37 0x00007f363744b66f clang::Sema::ActOnEndOfTranslationUnit() (/lib64/libclang-cpp.so.18.1+0x144b66f)
#<!-- -->38 0x00007f3636b690bd clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&lt;clang::DeclGroupRef&gt;&amp;, clang::Sema::ModuleImportState&amp;) (/lib64/libclang-cpp.so.18.1+0xb690bd)
#<!-- -->39 0x00007f3636a8ec6c clang::ParseAST(clang::Sema&amp;, bool, bool) (/lib64/libclang-cpp.so.18.1+0xa8ec6c)
#<!-- -->40 0x00007f3638d2a756 clang::FrontendAction::Execute() (/lib64/libclang-cpp.so.18.1+0x2d2a756)
#<!-- -->41 0x00007f3638c9d1b4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/lib64/libclang-cpp.so.18.1+0x2c9d1b4)
#<!-- -->42 0x00007f3638da5e36 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib64/libclang-cpp.so.18.1+0x2da5e36)
#<!-- -->43 0x000055b776841660 cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/usr/bin/clang-18+0x12660)
#<!-- -->44 0x000055b77683e3a8 (/usr/bin/clang-18+0xf3a8)
#<!-- -->45 0x00007f3638916389 (/lib64/libclang-cpp.so.18.1+0x2916389)
#<!-- -->46 0x00007f362f512a6e llvm::CrashRecoveryContext::RunSafely(llvm::function_ref&lt;void ()&gt;) (/lib64/libLLVM.so.18.1+0x912a6e)
#<!-- -->47 0x00007f36389160e0 clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const (/lib64/libclang-cpp.so.18.1+0x29160e0)
#<!-- -->48 0x00007f36388ddeac clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&amp;, clang::driver::Command const*&amp;, bool) const (/lib64/libclang-cpp.so.18.1+0x28ddeac)
#<!-- -->49 0x00007f36388de0ee clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;, bool) const (/lib64/libclang-cpp.so.18.1+0x28de0ee)
#<!-- -->50 0x00007f36388fa74c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;) (/lib64/libclang-cpp.so.18.1+0x28fa74c)
#<!-- -->51 0x000055b77683dc3d clang_main(int, char**, llvm::ToolContext const&amp;) (/usr/bin/clang-18+0xec3d)
#<!-- -->52 0x000055b77684a6e9 main (/usr/bin/clang-18+0x1b6e9)
#<!-- -->53 0x00007f362e42a1f0 __libc_start_call_main /usr/src/debug/glibc-2.39/csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#<!-- -->54 0x00007f362e42a2b9 call_init /usr/src/debug/glibc-2.39/csu/../csu/libc-start.c:128:20
#<!-- -->55 0x00007f362e42a2b9 __libc_start_main@<!-- -->GLIBC_2.2.5 /usr/src/debug/glibc-2.39/csu/../csu/libc-start.c:347:5
#<!-- -->56 0x000055b77683ab25 _start (/usr/bin/clang-18+0xbb25)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 18.1.4
Target: x86_64-suse-linux
Thread model: posix
InstalledDir: /usr/bin
clang++: note: diagnostic msg: 

Maybe this is a duplicate of #90669 clang-17 works fine.

Cheers,
André

@zyn0217 zyn0217 closed this as completed in 3d361b2 Jun 4, 2024
vedantparanjape-amd pushed a commit to vedantparanjape-amd/llvm-project that referenced this issue Jun 7, 2024
…93206)

This patch picks up llvm#78598 with the hope that we can address such
crashes in `tryCaptureVariable()` for unevaluated lambdas.

In addition to `tryCaptureVariable()`, this also contains several other
fixes on e.g. lambda parsing/dependencies.

Fixes llvm#63845
Fixes llvm#67260
Fixes llvm#69307
Fixes llvm#88081
Fixes llvm#89496
Fixes llvm#90669
Fixes llvm#91633
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants