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

[clang] crash on valid in isPackExpansion #116036

Open
vient opened this issue Nov 13, 2024 · 7 comments
Open

[clang] crash on valid in isPackExpansion #116036

vient opened this issue Nov 13, 2024 · 7 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" concepts C++20 concepts crash-on-valid lambda C++11 lambda expressions

Comments

@vient
Copy link
Member

vient commented Nov 13, 2024

Minified from real code (minification may not be the best since half of cvise passes crash or fail)

template <bool> using __bool_constant = int;
int invoke;
template <typename>
concept invocable = requires { invoke; };
template <template <typename> typename> struct Walk {
  static void traverse(auto)
    requires invocable<decltype([](auto...) {})>;
};
template <typename> using DoNotPrune = __bool_constant<false>;
template <template <typename> typename Prune = DoNotPrune>
auto for_each_leaf(auto value) {
  Walk<Prune>::traverse(value);
}
auto collect(int value) {
  for_each_leaf(value);
}

compiled with clang++-19 -std=c++23 -o test.o -c test.cpp produces this

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: clang++-19 -std=c++23 -o test.o -c test.cpp
1.      test.cpp:15:22: current parser token ')'
2.      test.cpp:14:25: parsing function body 'collect'
3.      test.cpp:14:25: in compound statement ('{}')
4.      test.cpp:11:6: instantiating function definition 'for_each_leaf<DoNotPrune, int>'
 #0 0x00007f1c43e1cb06 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xea3b06)
 #1 0x00007f1c43e1a7b0 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xea17b0)
 #2 0x00007f1c43e1bf64 llvm::sys::CleanupOnSignal(unsigned long) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xea2f64)
 #3 0x00007f1c43d6a6d0 (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xdf16d0)
 #4 0x00007f1c4ee28420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #5 0x00007f1c4bd46ffe clang::TemplateArgument::isPackExpansion() const (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1279ffe)
 #6 0x00007f1c4c86f2ac (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1da22ac)
 #7 0x00007f1c4c8287c6 clang::Sema::SubstType(clang::TypeLoc, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d5b7c6)
 #8 0x00007f1c4c82a81f clang::Sema::SubstParmVarDecl(clang::ParmVarDecl*, clang::MultiLevelTemplateArgumentList const&, int, std::optional<unsigned int>, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d5d81f)
 #9 0x00007f1c4c862f1a (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d95f1a)
#10 0x00007f1c4c8662da (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d992da)
#11 0x00007f1c4c864e1c (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d97e1c)
#12 0x00007f1c4c857f9e (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d8af9e)
#13 0x00007f1c4c86a2d7 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d9d2d7)
#14 0x00007f1c4c82865b (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d5b65b)
#15 0x00007f1c4c82f565 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d62565)
#16 0x00007f1c4c82fed0 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d62ed0)
#17 0x00007f1c4c859a24 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d8ca24)
#18 0x00007f1c4c8307c2 clang::Sema::SubstConstraintExpr(clang::Expr*, clang::MultiLevelTemplateArgumentList const&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d637c2)
#19 0x00007f1c4c1811b4 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x16b41b4)
#20 0x00007f1c4c179ec4 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x16acec4)
#21 0x00007f1c4c179c5c clang::Sema::CheckConstraintSatisfaction(clang::NamedDecl const*, llvm::ArrayRef<clang::Expr const*>, llvm::SmallVectorImpl<clang::Expr*>&, clang::MultiLevelTemplateArgumentList const&, clang::SourceRange, clang::ConstraintSatisfaction&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x16acc5c)
#22 0x00007f1c4c17ce2d clang::Sema::CheckInstantiatedFunctionTemplateConstraints(clang::SourceLocation, clang::FunctionDecl*, llvm::ArrayRef<clang::TemplateArgument>, clang::ConstraintSatisfaction&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x16afe2d)
#23 0x00007f1c4c77a4a9 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 ()>) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1cad4a9)
#24 0x00007f1c4c7d5bd7 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d08bd7)
#25 0x00007f1c4c0386ed clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x156b6ed)
#26 0x00007f1c4c77bf8b 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>)>) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1caef8b)
#27 0x00007f1c4c663c44 clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamOrder, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1b96c44)
#28 0x00007f1c4c6742fc (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1ba72fc)
#29 0x00007f1c4c6741d0 clang::Sema::AddOverloadedCallCandidates(clang::UnresolvedLookupExpr*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1ba71d0)
#30 0x00007f1c4c674510 clang::Sema::buildOverloadedCallSet(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::OverloadCandidateSet*, clang::ActionResult<clang::Expr*, true>*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1ba7510)
#31 0x00007f1c4c674810 clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1ba7810)
#32 0x00007f1c4c32725a clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x185a25a)
#33 0x00007f1c4c33aa3e clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x186da3e)
#34 0x00007f1c4c85a15a (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d8d15a)
#35 0x00007f1c4c82ed21 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d61d21)
#36 0x00007f1c4c85f89d (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d9289d)
#37 0x00007f1c4c82ecb4 clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d61cb4)
#38 0x00007f1c4c894b2b clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1dc7b2b)
#39 0x00007f1c4c0386ed clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x156b6ed)
#40 0x00007f1c4c77f8ff clang::Sema::DeduceReturnType(clang::FunctionDecl*, clang::SourceLocation, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1cb28ff)
#41 0x00007f1c4c3223e1 clang::Sema::DiagnoseUseOfDecl(clang::NamedDecl*, llvm::ArrayRef<clang::SourceLocation>, clang::ObjCInterfaceDecl const*, bool, bool, clang::ObjCInterfaceDecl*, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x18553e1)
#42 0x00007f1c4c674b30 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1ba7b30)
#43 0x00007f1c4c67491f clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1ba791f)
#44 0x00007f1c4c32725a clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x185a25a)
#45 0x00007f1c4c33aa3e clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x186da3e)
#46 0x00007f1c4b750e9c clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc83e9c)
#47 0x00007f1c4b754619 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc87619)
#48 0x00007f1c4b74de59 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc80e59)
#49 0x00007f1c4b74dd29 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc80d29)
#50 0x00007f1c4b7b5c15 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xce8c15)
#51 0x00007f1c4b7b3f30 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xce6f30)
#52 0x00007f1c4b7b3906 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xce6906)
#53 0x00007f1c4b7bc460 clang::Parser::ParseCompoundStatementBody(bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xcef460)
#54 0x00007f1c4b7bd582 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xcf0582)
#55 0x00007f1c4b7d737f clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xd0a37f)
#56 0x00007f1c4b719b44 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc4cb44)
#57 0x00007f1c4b7d63a3 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xd093a3)
#58 0x00007f1c4b7d5d5b clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xd08d5b)
#59 0x00007f1c4b7d4f77 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xd07f77)
#60 0x00007f1c4b7d3437 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xd06437)
#61 0x00007f1c4b701efe clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc34efe)
#62 0x00007f1c4d7a8bb5 clang::FrontendAction::Execute() (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2cdbbb5)
#63 0x00007f1c4d71e2a4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2c512a4)
#64 0x00007f1c4d824c9e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2d57c9e)
#65 0x0000560ce11456e0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-19/bin/clang+0x116e0)
#66 0x0000560ce11429e5 (/usr/lib/llvm-19/bin/clang+0xe9e5)
#67 0x00007f1c4d3bd9a9 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x28f09a9)
#68 0x00007f1c43d6a468 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xdf1468)
#69 0x00007f1c4d3bd34d clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x28f034d)
#70 0x00007f1c4d3839a9 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x28b69a9)
#71 0x00007f1c4d383c1e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x28b6c1e)
#72 0x00007f1c4d3a06fb clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x28d36fb)
#73 0x0000560ce114245f clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-19/bin/clang+0xe45f)
#74 0x0000560ce114f706 main (/usr/lib/llvm-19/bin/clang+0x1b706)
#75 0x00007f1c429b7083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#76 0x0000560ce114072e _start (/usr/lib/llvm-19/bin/clang+0xc72e)
clang++-19: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Ubuntu clang version 19.1.4 (++20241111014147+a3f0f1d004a6-1~exp1~20241111134204.61)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-19/bin
# Crash reproducer for Ubuntu clang version 19.1.4 (++20241111014147+a3f0f1d004a6-1~exp1~20241111134204.61)
# Driver args: "--driver-mode=g++" "-std=c++23" "-o" "test.o" "-c" "test.cpp"
# Original command:  "/usr/lib/llvm-19/bin/clang" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "test.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/tmp" "-fcoverage-compilation-dir=/tmp" "-resource-dir" "/usr/lib/llvm-19/lib/clang/19" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/14.2.0/../../../../include/c++/14.2.0" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/14.2.0/../../../../include/c++/14.2.0/x86_64-linux-gnu" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/14.2.0/../../../../include/c++/14.2.0/backward" "-internal-isystem" "/usr/lib/llvm-19/lib/clang/19/include" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/14.2.0/../../../../x86_64-linux-gnu/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-std=c++23" "-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fno-implicit-modules" "-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions" "-fcolor-diagnostics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "test.o" "-x" "c++" "test.cpp"
 "/usr/lib/llvm-19/bin/clang" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "test.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/tmp" "-fcoverage-compilation-dir=/tmp" "-std=c++23" "-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fno-implicit-modules" "-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions" "-fcolor-diagnostics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-x" "c++" "test-5fa5ce.cpp"

Somehow can't reproduce in godbolt but got another (?) crash with assertion trunk: https://godbolt.org/z/abvenc4Md

@github-actions github-actions bot added the clang Clang issues not falling into any other category label Nov 13, 2024
@vient
Copy link
Member Author

vient commented Nov 13, 2024

godbolt has clang version 19.1.0 (https://github.com/llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4) a4bf6cd - guess it means that crash was introduced between 19.1.0 and 19.1.3, and is also missing in main.

On the other hand, I have clang 19.1.0-rc4 built and also one around 19.1.1, both crash.

@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] regression:19 Regression in 19 release and removed clang Clang issues not falling into any other category labels Nov 13, 2024
@llvmbot
Copy link

llvmbot commented Nov 13, 2024

@llvm/issue-subscribers-clang-frontend

Author: vient (vient)

Minified from real code (minification may not be the best since half of cvise passes crash or fail) ```cpp template <bool> using __bool_constant = int; int invoke; template <typename> concept invocable = requires { invoke; }; template <template <typename> typename> struct Walk { static void traverse(auto) requires invocable<decltype([](auto...) {})>; }; template <typename> using DoNotPrune = __bool_constant<false>; template <template <typename> typename Prune = DoNotPrune> auto for_each_leaf(auto value) { Walk<Prune>::traverse(value); } auto collect(int value) { for_each_leaf(value); } ``` compiled with `clang++-19 -std=c++23 -o test.o -c test.cpp` produces this ``` 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: clang++-19 -std=c++23 -o test.o -c test.cpp 1. test.cpp:15:22: current parser token ')' 2. test.cpp:14:25: parsing function body 'collect' 3. test.cpp:14:25: in compound statement ('{}') 4. test.cpp:11:6: instantiating function definition 'for_each_leaf<DoNotPrune, int>' #0 0x00007f1c43e1cb06 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xea3b06) #1 0x00007f1c43e1a7b0 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xea17b0) #2 0x00007f1c43e1bf64 llvm::sys::CleanupOnSignal(unsigned long) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xea2f64) #3 0x00007f1c43d6a6d0 (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xdf16d0) #4 0x00007f1c4ee28420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420) #5 0x00007f1c4bd46ffe clang::TemplateArgument::isPackExpansion() const (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1279ffe) #6 0x00007f1c4c86f2ac (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1da22ac) #7 0x00007f1c4c8287c6 clang::Sema::SubstType(clang::TypeLoc, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d5b7c6) #8 0x00007f1c4c82a81f clang::Sema::SubstParmVarDecl(clang::ParmVarDecl*, clang::MultiLevelTemplateArgumentList const&, int, std::optional<unsigned int>, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d5d81f) #9 0x00007f1c4c862f1a (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d95f1a) #10 0x00007f1c4c8662da (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d992da) #11 0x00007f1c4c864e1c (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d97e1c) #12 0x00007f1c4c857f9e (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d8af9e) #13 0x00007f1c4c86a2d7 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d9d2d7) #14 0x00007f1c4c82865b (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d5b65b) #15 0x00007f1c4c82f565 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d62565) #16 0x00007f1c4c82fed0 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d62ed0) #17 0x00007f1c4c859a24 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d8ca24) #18 0x00007f1c4c8307c2 clang::Sema::SubstConstraintExpr(clang::Expr*, clang::MultiLevelTemplateArgumentList const&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d637c2) #19 0x00007f1c4c1811b4 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x16b41b4) #20 0x00007f1c4c179ec4 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x16acec4) #21 0x00007f1c4c179c5c clang::Sema::CheckConstraintSatisfaction(clang::NamedDecl const*, llvm::ArrayRef<clang::Expr const*>, llvm::SmallVectorImpl<clang::Expr*>&, clang::MultiLevelTemplateArgumentList const&, clang::SourceRange, clang::ConstraintSatisfaction&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x16acc5c) #22 0x00007f1c4c17ce2d clang::Sema::CheckInstantiatedFunctionTemplateConstraints(clang::SourceLocation, clang::FunctionDecl*, llvm::ArrayRef<clang::TemplateArgument>, clang::ConstraintSatisfaction&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x16afe2d) #23 0x00007f1c4c77a4a9 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 ()>) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1cad4a9) #24 0x00007f1c4c7d5bd7 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d08bd7) #25 0x00007f1c4c0386ed clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x156b6ed) #26 0x00007f1c4c77bf8b 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>)>) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1caef8b) #27 0x00007f1c4c663c44 clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamOrder, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1b96c44) #28 0x00007f1c4c6742fc (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1ba72fc) #29 0x00007f1c4c6741d0 clang::Sema::AddOverloadedCallCandidates(clang::UnresolvedLookupExpr*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1ba71d0) #30 0x00007f1c4c674510 clang::Sema::buildOverloadedCallSet(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::OverloadCandidateSet*, clang::ActionResult<clang::Expr*, true>*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1ba7510) #31 0x00007f1c4c674810 clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1ba7810) #32 0x00007f1c4c32725a clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x185a25a) #33 0x00007f1c4c33aa3e clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x186da3e) #34 0x00007f1c4c85a15a (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d8d15a) #35 0x00007f1c4c82ed21 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d61d21) #36 0x00007f1c4c85f89d (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d9289d) #37 0x00007f1c4c82ecb4 clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d61cb4) #38 0x00007f1c4c894b2b clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1dc7b2b) #39 0x00007f1c4c0386ed clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x156b6ed) #40 0x00007f1c4c77f8ff clang::Sema::DeduceReturnType(clang::FunctionDecl*, clang::SourceLocation, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1cb28ff) #41 0x00007f1c4c3223e1 clang::Sema::DiagnoseUseOfDecl(clang::NamedDecl*, llvm::ArrayRef<clang::SourceLocation>, clang::ObjCInterfaceDecl const*, bool, bool, clang::ObjCInterfaceDecl*, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x18553e1) #42 0x00007f1c4c674b30 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1ba7b30) #43 0x00007f1c4c67491f clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1ba791f) #44 0x00007f1c4c32725a clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x185a25a) #45 0x00007f1c4c33aa3e clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x186da3e) #46 0x00007f1c4b750e9c clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc83e9c) #47 0x00007f1c4b754619 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc87619) #48 0x00007f1c4b74de59 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc80e59) #49 0x00007f1c4b74dd29 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc80d29) #50 0x00007f1c4b7b5c15 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xce8c15) #51 0x00007f1c4b7b3f30 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xce6f30) #52 0x00007f1c4b7b3906 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xce6906) #53 0x00007f1c4b7bc460 clang::Parser::ParseCompoundStatementBody(bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xcef460) #54 0x00007f1c4b7bd582 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xcf0582) #55 0x00007f1c4b7d737f clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xd0a37f) #56 0x00007f1c4b719b44 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc4cb44) #57 0x00007f1c4b7d63a3 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xd093a3) #58 0x00007f1c4b7d5d5b clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xd08d5b) #59 0x00007f1c4b7d4f77 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xd07f77) #60 0x00007f1c4b7d3437 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xd06437) #61 0x00007f1c4b701efe clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc34efe) #62 0x00007f1c4d7a8bb5 clang::FrontendAction::Execute() (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2cdbbb5) #63 0x00007f1c4d71e2a4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2c512a4) #64 0x00007f1c4d824c9e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2d57c9e) #65 0x0000560ce11456e0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-19/bin/clang+0x116e0) #66 0x0000560ce11429e5 (/usr/lib/llvm-19/bin/clang+0xe9e5) #67 0x00007f1c4d3bd9a9 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x28f09a9) #68 0x00007f1c43d6a468 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xdf1468) #69 0x00007f1c4d3bd34d clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x28f034d) #70 0x00007f1c4d3839a9 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x28b69a9) #71 0x00007f1c4d383c1e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x28b6c1e) #72 0x00007f1c4d3a06fb clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x28d36fb) #73 0x0000560ce114245f clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-19/bin/clang+0xe45f) #74 0x0000560ce114f706 main (/usr/lib/llvm-19/bin/clang+0x1b706) #75 0x00007f1c429b7083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083) #76 0x0000560ce114072e _start (/usr/lib/llvm-19/bin/clang+0xc72e) clang++-19: error: clang frontend command failed with exit code 139 (use -v to see invocation) Ubuntu clang version 19.1.4 (++20241111014147+a3f0f1d004a6-1~exp1~20241111134204.61) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/lib/llvm-19/bin ```
# Crash reproducer for Ubuntu clang version 19.1.4 (++20241111014147+a3f0f1d004a6-1~exp1~20241111134204.61)
# Driver args: "--driver-mode=g++" "-std=c++23" "-o" "test.o" "-c" "test.cpp"
# Original command:  "/usr/lib/llvm-19/bin/clang" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "test.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/tmp" "-fcoverage-compilation-dir=/tmp" "-resource-dir" "/usr/lib/llvm-19/lib/clang/19" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/14.2.0/../../../../include/c++/14.2.0" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/14.2.0/../../../../include/c++/14.2.0/x86_64-linux-gnu" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/14.2.0/../../../../include/c++/14.2.0/backward" "-internal-isystem" "/usr/lib/llvm-19/lib/clang/19/include" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/14.2.0/../../../../x86_64-linux-gnu/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-std=c++23" "-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fno-implicit-modules" "-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions" "-fcolor-diagnostics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "test.o" "-x" "c++" "test.cpp"
 "/usr/lib/llvm-19/bin/clang" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "test.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/tmp" "-fcoverage-compilation-dir=/tmp" "-std=c++23" "-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fno-implicit-modules" "-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions" "-fcolor-diagnostics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-x" "c++" "test-5fa5ce.cpp"

Somehow can't reproduce in godbolt but got another (?) crash with assertion trunk: https://godbolt.org/z/abvenc4Md

@shafik
Copy link
Collaborator

shafik commented Nov 14, 2024

So the original code only crashes on clang-19 but the example you provides crashed back to clang-16: https://godbolt.org/z/MK3q56T3K

w/o the reproducer that only crashes on clang-19 we can't dig into the recent regression. Do you have a non minimized version?

@vient
Copy link
Member Author

vient commented Nov 14, 2024

I did not say that original code crashes only with clang-19, I only tried clang-19. I'm pretty sure that crash stack trace with minified version is the same as with the original. regression:19 tag was not placed by me.

Thing that bugs me is that clang from llvm apt repo crashes but clang in godbolt (without assertions) does not.

@vient
Copy link
Member Author

vient commented Nov 14, 2024

Tested locally with clang 18 and 19 from llvm repos (for Ubuntu 20.04) as well as my own builds. Results:

  • clang-19 from repo: crash
  • clang-18 from repo: ok
  • my clang-19: crash
  • my clang-18: crash

Also found my build with debug info, here is the stack trace

Stack dump:
0.      Program arguments: twix-clang++-19 -std=c++23 -c test.cpp -o test.o
1.      test.cpp:15:22: current parser token ')'
2.      test.cpp:14:25: parsing function body 'collect'
3.      test.cpp:14:25: in compound statement ('{}')
4.      test.cpp:11:6: instantiating function definition 'for_each_leaf<DoNotPrune, int>'
 #0 0x000000000443e4e2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /packages/twix-clang/work/llvm-project/llvm/lib/Support/Unix/Signals.inc:727:8
 #1 0x000000000443e274 llvm::sys::RunSignalHandlers() /packages/twix-clang/work/llvm-project/llvm/lib/Support/Signals.cpp:106:18
 #2 0x000000000443e274 llvm::sys::CleanupOnSignal(unsigned long) /packages/twix-clang/work/llvm-project/llvm/lib/Support/Unix/Signals.inc:367:3
 #3 0x00000000043ff41d (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /packages/twix-clang/work/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:73:5
 #4 0x00000000043ff5c4 CrashRecoverySignalHandler(int) (.llvm.1912282772267760858) /packages/twix-clang/work/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:391:1
 #5 0x00007f77a6e1c420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #6 0x0000000001ea564c clang::QualType::getTypePtr() const /packages/twix-clang/work/llvm-project/clang/include/clang/AST/Type.h:7747:26
 #7 0x0000000001ea564c clang::QualType::isCanonical() const /packages/twix-clang/work/llvm-project/clang/include/clang/AST/Type.h:7804:10
 #8 0x0000000001ea564c clang::ASTContext::getSubstTemplateTypeParmType(clang::QualType, clang::Decl*, unsigned int, std::optional<unsigned int>) const /packages/twix-clang/work/llvm-project/clang/lib/AST/ASTContext.cpp:5216:43
 #9 0x0000000001ea564c (anonymous namespace)::TemplateInstantiator::BuildSubstTemplateTypeParmType(clang::TypeLocBuilder&, bool, bool, clang::Decl*, unsigned int, std::optional<unsigned int>, clang::TemplateArgument, clang::SourceLocation) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:2449:39
#10 0x0000000001ea564c (anonymous namespace)::TemplateInstantiator::TransformTemplateTypeParmType(clang::TypeLocBuilder&, clang::TemplateTypeParmTypeLoc, bool) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:2521:12
#11 0x0000000001ea564c clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateTypeParmType(clang::TypeLocBuilder&, clang::TemplateTypeParmTypeLoc) /packages/twix-clang/work/llvm-project/clang/lib/Sema/TreeTransform.h:6857:23
#12 0x0000000001ea564c clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) (.llvm.521184534843296507) /packages/twix-clang/work/stage2-prof-use-lto/tools/clang/include/clang/AST/TypeNodes.inc:77:1
#13 0x0000000001e6d9a5 llvm::PointerUnion<clang::Type const*, clang::ExtQuals const*>::isNull() const /packages/twix-clang/work/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:142:33
#14 0x0000000001e6d9a5 clang::QualType::isNull() const /packages/twix-clang/work/llvm-project/clang/include/clang/AST/Type.h:1009:31
#15 0x0000000001e6d9a5 clang::Sema::SubstType(clang::TypeLoc, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:2833:14
#16 0x00000000031f7b3a clang::Sema::SubstParmVarDecl(clang::ParmVarDecl*, clang::MultiLevelTemplateArgumentList const&, int, std::optional<unsigned int>, bool, bool) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:3082:10
#17 0x00000000031f47f6 (anonymous namespace)::TemplateInstantiator::TransformFunctionTypeParam(clang::ParmVarDecl*, int, std::optional<unsigned int>, bool) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:2420:26
#18 0x00000000031f47f6 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformFunctionTypeParams(clang::SourceLocation, llvm::ArrayRef<clang::ParmVarDecl*>, clang::QualType const*, clang::FunctionType::ExtParameterInfo const*, llvm::SmallVectorImpl<clang::QualType>&, llvm::SmallVectorImpl<clang::ParmVarDecl*>*, clang::Sema::ExtParameterInfoBuilder&, unsigned int*) /packages/twix-clang/work/llvm-project/clang/lib/Sema/TreeTransform.h:6011:30
#19 0x00000000031f8742 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformFunctionTypeParams(clang::SourceLocation, llvm::ArrayRef<clang::ParmVarDecl*>, clang::QualType const*, clang::FunctionType::ExtParameterInfo const*, llvm::SmallVectorImpl<clang::QualType>&, llvm::SmallVectorImpl<clang::ParmVarDecl*>*, clang::Sema::ExtParameterInfoBuilder&) /packages/twix-clang/work/llvm-project/clang/lib/Sema/TreeTransform.h:733:25
#20 0x00000000031f8742 clang::QualType clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformFunctionProtoType<clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformLambdaExpr(clang::LambdaExpr*)::'lambda'(clang::TypeLocBuilder&, clang::FunctionProtoTypeLoc)::operator()(clang::TypeLocBuilder&, clang::FunctionProtoTypeLoc) const::'lambda'(clang::FunctionProtoType::ExceptionSpecInfo&, bool&)>(clang::TypeLocBuilder&, clang::FunctionProtoTypeLoc, clang::CXXRecordDecl*, clang::Qualifiers, clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformLambdaExpr(clang::LambdaExpr*)::'lambda'(clang::TypeLocBuilder&, clang::FunctionProtoTypeLoc)::operator()(clang::TypeLocBuilder&, clang::FunctionProtoTypeLoc) const::'lambda'(clang::FunctionProtoType::ExceptionSpecInfo&, bool&)) /packages/twix-clang/work/llvm-project/clang/lib/Sema/TreeTransform.h:6245:22
#21 0x000000000224f081 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformLambdaExpr(clang::LambdaExpr*)::'lambda'(clang::TypeLocBuilder&, clang::FunctionProtoTypeLoc)::operator()(clang::TypeLocBuilder&, clang::FunctionProtoTypeLoc) const /packages/twix-clang/work/llvm-project/clang/lib/Sema/TreeTransform.h:14567:20
#22 0x000000000224f081 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformLambdaExpr(clang::LambdaExpr*) /packages/twix-clang/work/llvm-project/clang/lib/Sema/TreeTransform.h:14587:23
#23 0x0000000001e86f96 clang::ActionResult<clang::Expr*, true>::isInvalid() const /packages/twix-clang/work/llvm-project/clang/include/clang/Sema/Ownership.h:199:41
#24 0x0000000001e86f96 (anonymous namespace)::TemplateInstantiator::TransformLambdaExpr(clang::LambdaExpr*) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:1663:18
#25 0x0000000001e86f96 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) (.llvm.521184534843296507) /packages/twix-clang/work/stage2-prof-use-lto/tools/clang/include/clang/AST/StmtNodes.inc:340:1
#26 0x0000000001e9a9df clang::ActionResult<clang::Expr*, true>::isInvalid() const /packages/twix-clang/work/llvm-project/clang/include/clang/Sema/Ownership.h:199:41
#27 0x0000000001e9a9df clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformDecltypeType(clang::TypeLocBuilder&, clang::DecltypeTypeLoc) /packages/twix-clang/work/llvm-project/clang/lib/Sema/TreeTransform.h:6609:9
#28 0x0000000001e9a9df clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) (.llvm.521184534843296507) /packages/twix-clang/work/stage2-prof-use-lto/tools/clang/include/clang/AST/TypeNodes.inc:39:1
#29 0x0000000001e951d3 llvm::PointerUnion<clang::Type const*, clang::ExtQuals const*>::isNull() const /packages/twix-clang/work/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:142:33
#30 0x0000000001e951d3 clang::QualType::isNull() const /packages/twix-clang/work/llvm-project/clang/include/clang/AST/Type.h:1009:31
#31 0x0000000001e951d3 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeSourceInfo*) /packages/twix-clang/work/llvm-project/clang/lib/Sema/TreeTransform.h:4979:14
#32 0x0000000001e951d3 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateArgument(clang::TemplateArgumentLoc const&, clang::TemplateArgumentLoc&, bool) /packages/twix-clang/work/llvm-project/clang/lib/Sema/TreeTransform.h:4709:23
#33 0x0000000001e951d3 (anonymous namespace)::TemplateInstantiator::TransformTemplateArgument(clang::TemplateArgumentLoc const&, clang::TemplateArgumentLoc&, bool) (.llvm.521184534843296507) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:1605:25
#34 0x0000000001e9310d bool clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateArguments<clang::TemplateArgumentLoc const*>(clang::TemplateArgumentLoc const*, clang::TemplateArgumentLoc const*, clang::TemplateArgumentListInfo&, bool) /packages/twix-clang/work/llvm-project/clang/lib/Sema/TreeTransform.h:4933:9
#35 0x0000000001e9310d clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateArguments(clang::TemplateArgumentLoc const*, unsigned int, clang::TemplateArgumentListInfo&, bool) /packages/twix-clang/work/llvm-project/clang/lib/Sema/TreeTransform.h:629:12
#36 0x0000000001e9310d clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformConceptSpecializationExpr(clang::ConceptSpecializationExpr*) /packages/twix-clang/work/llvm-project/clang/lib/Sema/TreeTransform.h:13863:20
#37 0x0000000001e6eb51 clang::Sema::SubstExpr(clang::Expr*, clang::MultiLevelTemplateArgumentList const&) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:4262:23
#38 0x0000000001e6eb51 clang::Sema::SubstConstraintExpr(clang::Expr*, clang::MultiLevelTemplateArgumentList const&) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:4270:10
#39 0x0000000001e6eb51 calculateConstraintSatisfaction(clang::Sema&, clang::NamedDecl const*, clang::SourceLocation, clang::MultiLevelTemplateArgumentList const&, clang::Expr const*, clang::ConstraintSatisfaction&)::ConstraintEvaluator::EvaluateAtomicConstraint(clang::Expr const*) const /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaConcept.cpp:476:15
#40 0x0000000001e6eb51 clang::ActionResult<clang::Expr*, true> calculateConstraintSatisfaction<calculateConstraintSatisfaction(clang::Sema&, clang::NamedDecl const*, clang::SourceLocation, clang::MultiLevelTemplateArgumentList const&, clang::Expr const*, clang::ConstraintSatisfaction&)::ConstraintEvaluator>(clang::Sema&, clang::Expr const*, clang::ConstraintSatisfaction&, calculateConstraintSatisfaction(clang::Sema&, clang::NamedDecl const*, clang::SourceLocation, clang::MultiLevelTemplateArgumentList const&, clang::Expr const*, clang::ConstraintSatisfaction&)::ConstraintEvaluator const&) (.llvm.6092503570190903660) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaConcept.cpp:351:17
#41 0x00000000030a0efe clang::ActionResult<clang::Expr*, true>::isInvalid() const /packages/twix-clang/work/llvm-project/clang/include/clang/Sema/Ownership.h:199:41
#42 0x00000000030a0efe CheckConstraintSatisfaction(clang::Sema&, clang::NamedDecl const*, llvm::ArrayRef<clang::Expr const*>, llvm::SmallVectorImpl<clang::Expr*>&, clang::MultiLevelTemplateArgumentList const&, clang::SourceRange, clang::ConstraintSatisfaction&) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaConcept.cpp:600:13
#43 0x00000000030a0efe clang::Sema::CheckConstraintSatisfaction(clang::NamedDecl const*, llvm::ArrayRef<clang::Expr const*>, llvm::SmallVectorImpl<clang::Expr*>&, clang::MultiLevelTemplateArgumentList const&, clang::SourceRange, clang::ConstraintSatisfaction&) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaConcept.cpp:658:7
#44 0x0000000002500e6e clang::Sema::CheckInstantiatedFunctionTemplateConstraints(clang::SourceLocation, clang::FunctionDecl*, llvm::ArrayRef<clang::TemplateArgument>, clang::ConstraintSatisfaction&) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaConcept.cpp:1113:10
#45 0x0000000002500e6e 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 ()>) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:3920:9
#46 0x0000000002500e6e 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>)>)::$_2::operator()() const /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:4577:14
#47 0x0000000002500e6e 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>)>)::$_2>(long) (.llvm.16470972791884804529) /packages/twix-clang/work/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#48 0x0000000001e2f2ca 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>)>) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:4584:10
#49 0x0000000001e2f2ca clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamOrder, bool) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaOverload.cpp:7677:40
#50 0x0000000001e2f2ca AddOverloadedCallCandidate(clang::Sema&, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaOverload.cpp:13479:7
#51 0x0000000001e2f2ca clang::Sema::AddOverloadedCallCandidates(clang::UnresolvedLookupExpr*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaOverload.cpp:13533:5
#52 0x0000000002234ef4 clang::Sema::getLangOpts() const /packages/twix-clang/work/llvm-project/clang/include/clang/Sema/Sema.h:593:51
#53 0x0000000002234ef4 clang::Sema::buildOverloadedCallSet(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::OverloadCandidateSet*, clang::ActionResult<clang::Expr*, true>*) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaOverload.cpp:13841:7
#54 0x0000000002234ef4 clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaOverload.cpp:14047:7
#55 0x000000000223166a clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaExpr.cpp:6474:16
#56 0x000000000223166a clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaExpr.cpp:6360:7
#57 0x0000000001e84142 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::RebuildCallExpr(clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) /packages/twix-clang/work/llvm-project/clang/lib/Sema/TreeTransform.h:2837:22
#58 0x0000000001e84142 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCallExpr(clang::CallExpr*) /packages/twix-clang/work/llvm-project/clang/lib/Sema/TreeTransform.h:12313:23
#59 0x0000000001ef80ae clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::getSema() const /packages/twix-clang/work/llvm-project/clang/lib/Sema/TreeTransform.h:152:34
#60 0x0000000001ef80ae clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*, clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::StmtDiscardKind) /packages/twix-clang/work/llvm-project/clang/lib/Sema/TreeTransform.h:4114:14
#61 0x0000000001ef80ae clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) /packages/twix-clang/work/llvm-project/clang/lib/Sema/TreeTransform.h:7828:38
#62 0x0000000001ef80ae clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*) (.llvm.521184534843296507) /packages/twix-clang/work/llvm-project/clang/lib/Sema/TreeTransform.h:7810:23
#63 0x000000000229a19a clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:4233:23
#64 0x000000000229a19a clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:5186:14
#65 0x0000000002296589 clang::Sema::DeduceReturnType(clang::FunctionDecl*, clang::SourceLocation, bool) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:5343:25
#66 0x000000000238f599 clang::Sema::DiagnoseUseOfDecl(clang::NamedDecl*, llvm::ArrayRef<clang::SourceLocation>, clang::ObjCInterfaceDecl const*, bool, bool, clang::ObjCInterfaceDecl*, bool) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaExpr.cpp:0:9
#67 0x000000000223502b FinishOverloadedCallExpr(clang::Sema&, clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, clang::OverloadCandidateSet*, clang::OverloadCandidate**, clang::OverloadingResult, bool) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaOverload.cpp:13929:17
#68 0x000000000223502b clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaOverload.cpp:14076:10
#69 0x000000000223166a clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaExpr.cpp:6474:16
#70 0x000000000223166a clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) /packages/twix-clang/work/llvm-project/clang/lib/Sema/SemaExpr.cpp:6360:7
#71 0x0000000001d364ed clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) /packages/twix-clang/work/llvm-project/clang/lib/Parse/ParseExpr.cpp:2243:23
#72 0x0000000001d32e38 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) /packages/twix-clang/work/llvm-project/clang/lib/Parse/ParseExpr.cpp:1945:7
#73 0x0000000001d244bb clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) /packages/twix-clang/work/llvm-project/clang/lib/Parse/ParseExpr.cpp:718:7
#74 0x0000000001d244bb clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) /packages/twix-clang/work/llvm-project/clang/lib/Parse/ParseExpr.cpp:182:20
#75 0x0000000001d244bb clang::Parser::ParseExpression(clang::Parser::TypeCastState) /packages/twix-clang/work/llvm-project/clang/lib/Parse/ParseExpr.cpp:133:18
#76 0x0000000001d244bb clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) /packages/twix-clang/work/llvm-project/clang/lib/Parse/ParseStmt.cpp:554:19
#77 0x0000000001d244bb clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) /packages/twix-clang/work/llvm-project/clang/lib/Parse/ParseStmt.cpp:292:14
#78 0x0000000001d244bb clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) /packages/twix-clang/work/llvm-project/clang/lib/Parse/ParseStmt.cpp:124:20
#79 0x0000000001d244bb clang::Parser::ParseCompoundStatementBody(bool) /packages/twix-clang/work/llvm-project/clang/lib/Parse/ParseStmt.cpp:1248:11
#80 0x0000000001d2288b clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) /packages/twix-clang/work/llvm-project/clang/lib/Parse/ParseStmt.cpp:2526:21
#81 0x0000000002288100 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) /packages/twix-clang/work/llvm-project/clang/lib/Parse/Parser.cpp:0:10
#82 0x00000000027b918d clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) /packages/twix-clang/work/llvm-project/clang/lib/Parse/ParseDecl.cpp:0:0
#83 0x00000000023484cc clang::Parser::ObjCDeclContextSwitch::~ObjCDeclContextSwitch() /packages/twix-clang/work/llvm-project/clang/include/clang/Parse/Parser.h:1097:11
#84 0x00000000023484cc clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /packages/twix-clang/work/llvm-project/clang/lib/Parse/Parser.cpp:1272:3
#85 0x00000000023484cc clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /packages/twix-clang/work/llvm-project/clang/lib/Parse/Parser.cpp:1074:14
#86 0x00000000023454cc clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /packages/twix-clang/work/llvm-project/clang/lib/Parse/Parser.cpp:763:10
#87 0x0000000001fdcfb2 clang::ParseAST(clang::Sema&, bool, bool) /packages/twix-clang/work/llvm-project/clang/lib/Parse/ParseAST.cpp:170:5
#88 0x0000000003caca2c clang::CompilerInstance::shouldBuildGlobalModuleIndex() const /packages/twix-clang/work/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:84:34
#89 0x0000000003caca2c clang::FrontendAction::Execute() /packages/twix-clang/work/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1082:10
#90 0x0000000003cac48e llvm::Error::getPtr() const /packages/twix-clang/work/llvm-project/llvm/include/llvm/Support/Error.h:282:12
#91 0x0000000003cac48e llvm::Error::operator bool() /packages/twix-clang/work/llvm-project/llvm/include/llvm/Support/Error.h:242:16
#92 0x0000000003cac48e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /packages/twix-clang/work/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1061:23
#93 0x0000000003cac1fc clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /packages/twix-clang/work/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:280:25
#94 0x0000000003cb2dca cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /packages/twix-clang/work/llvm-project/clang/tools/driver/cc1_main.cpp:284:15
#95 0x0000000003cb1c42 llvm::SmallVectorBase<unsigned int>::size() const /packages/twix-clang/work/llvm-project/llvm/include/llvm/ADT/SmallVector.h:92:32
#96 0x0000000003cb1c42 llvm::SmallVectorTemplateCommon<void*, void>::end() /packages/twix-clang/work/llvm-project/llvm/include/llvm/ADT/SmallVector.h:283:37
#97 0x0000000003cb1c42 llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul, 128ul>::~BumpPtrAllocatorImpl() /packages/twix-clang/work/llvm-project/llvm/include/llvm/Support/Allocator.h:98:42
#98 0x0000000003cb1c42 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) (.llvm.5293471576631646810) /packages/twix-clang/work/llvm-project/clang/tools/driver/driver.cpp:226:1
#99 0x000000000485f2a9 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_0::operator()() const /packages/twix-clang/work/llvm-project/clang/lib/Driver/Job.cpp:440:30
#100 0x000000000485f2a9 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::$_0>(long) (.llvm.8732357286314457777) /packages/twix-clang/work/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#101 0x0000000003dd8c6c llvm::function_ref<void ()>::operator()() const /packages/twix-clang/work/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:0:12
#102 0x0000000003dd8c6c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /packages/twix-clang/work/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:426:3
#103 0x0000000003dd8aa5 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const /packages/twix-clang/work/llvm-project/clang/lib/Driver/Job.cpp:440:7
#104 0x0000000003cbb718 std::_Function_base::_M_empty() const /usr/lib/gcc/x86_64-linux-gnu/14.0.0/../../../../include/c++/14.0.0/bits/std_function.h:247:37
#105 0x0000000003cbb718 std::function<void (clang::driver::Command const&, int)>::operator bool() const /usr/lib/gcc/x86_64-linux-gnu/14.0.0/../../../../include/c++/14.0.0/bits/std_function.h:574:17
#106 0x0000000003cbb718 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const /packages/twix-clang/work/llvm-project/clang/lib/Driver/Compilation.cpp:200:7
#107 0x0000000003cbb4ab clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const /packages/twix-clang/work/llvm-project/clang/lib/Driver/Compilation.cpp:253:13
#108 0x0000000003cbabcf llvm::SmallVectorBase<unsigned int>::empty() const /packages/twix-clang/work/llvm-project/llvm/include/llvm/ADT/SmallVector.h:95:46
#109 0x0000000003cbabcf clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) /packages/twix-clang/work/llvm-project/clang/lib/Driver/Driver.cpp:1943:23
#110 0x0000000003cb692f clang_main(int, char**, llvm::ToolContext const&) /packages/twix-clang/work/llvm-project/clang/tools/driver/driver.cpp:0:21
#111 0x0000000003b3ee32 main /packages/twix-clang/work/stage2-prof-use-lto/tools/clang/tools/driver/clang-driver.cpp:17:10
#112 0x00007f77a6771083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#113 0x0000000003fa705e _start (/usr/local/twix-clang-19/bin/clang+0x3fa705e)
twix-clang++-19: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Pinely clang version 19.1.0-rc4 (https://github.com/llvm/llvm-project.git 0c641568515a797473394694f05937e1f1913d87)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/local/twix-clang-19/bin

guess isPackExpansion in issue name may be wrong

@zyn0217
Copy link
Contributor

zyn0217 commented Nov 15, 2024

Reduced to

template <typename>
concept invocable = true;

template <int Depth = 0>
struct Walk {
  static int traverse(auto /*Depth=1*/)
    requires invocable<decltype([](auto /*depth of invented
                                           TemplateTypeParmDecl=1, depth of the
                                           ParmVarDecl=2*/
                                   ...) {})>;
};

int res = Walk<>::traverse(42);

https://gcc.godbolt.org/z/dMK3s5P9c

The template depth of the lambda is incorrect: the invented TemplateTypeParmDecl is of depth 1, while the depth of the ParmVarDecl is 2. Logically the depth of that for Walk should be 0, that for traverse should be 1, and the lambda should live in depth 2, respectively. So this mismatch confuses the instantiator, hence the crash.

We don't have any template arguments for the unevaluated lambda to be turned into a non-dependent expression, so we shouldn't really be evaluating the constraint satisfaction.

However, we don't have any mechanism for it to skip dependent constraint evaluation IIRC (whereas we do have such for compound requirements), so even if we managed to correct the depth of the invented template parameter of the inner lambda, it would still run into a crash because the substituted expression is still dependent.

You're probably seeing intermittent crashes because, without an assertion build, it would be UB for clang to proceed with a wrong template argument type where it's expecting a pack.

@zyn0217 zyn0217 added concepts C++20 concepts crash-on-valid lambda C++11 lambda expressions and removed crash Prefer [crash-on-valid] or [crash-on-invalid] regression:19 Regression in 19 release labels Nov 15, 2024
@shafik
Copy link
Collaborator

shafik commented Nov 15, 2024

CC @erichkeane

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" concepts C++20 concepts crash-on-valid lambda C++11 lambda expressions
Projects
None yet
Development

No branches or pull requests

5 participants