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] Assertion `E != nullptr' failed. crashed at clang::NormalizedConstraint::fromConstraintExpr(clang::Sema&, clang::NamedDecl*, clang::Expr const*) #115004

Open
yijan4845 opened this issue Nov 5, 2024 · 2 comments
Labels
c++20 clang:frontend:fuzzer clang:frontend Language frontend issues, e.g. anything involving "Sema" crash-on-invalid regression

Comments

@yijan4845
Copy link

This testcase is generated by a fuzzer.

Compiler Explorer: https://godbolt.org/z/P1xE1dEx1

This invalid code will crash on Clang Assertion Trunk.

template <typename d> concept g = 0;
template <g> struct h;
template <g d>
struct h<d>;

This won't crash in clang-19.

Stack dump:

clang++: /root/llvm-project/clang/lib/Sema/SemaConcept.cpp:1584: static std::optional<clang::NormalizedConstraint> clang::NormalizedConstraint::fromConstraintExpr(clang::Sema&, clang::NamedDecl*, const clang::Expr*): Assertion `E != nullptr' 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 -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 <source>
1.	<source>:4:12: current parser token ';'
 #0 0x0000000003be9e28 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3be9e28)
 #1 0x0000000003be7b2c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3be7b2c)
 #2 0x0000000003b35468 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007759bfe42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007759bfe969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007759bfe42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007759bfe287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007759bfe2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007759bfe39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x00000000069e2ad0 clang::NormalizedConstraint::fromConstraintExpr(clang::Sema&, clang::NamedDecl*, clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69e2ad0)
#10 0x00000000069e2b63 clang::NormalizedConstraint::fromConstraintExprs(clang::Sema&, clang::NamedDecl*, llvm::ArrayRef<clang::Expr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69e2b63)
#11 0x00000000069e1f79 clang::Sema::getNormalizedAssociatedConstraints(clang::NamedDecl*, llvm::ArrayRef<clang::Expr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69e1f79)
#12 0x00000000069e25e3 clang::NormalizedConstraint::fromConstraintExpr(clang::Sema&, clang::NamedDecl*, clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69e25e3)
#13 0x00000000069e2b63 clang::NormalizedConstraint::fromConstraintExprs(clang::Sema&, clang::NamedDecl*, llvm::ArrayRef<clang::Expr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69e2b63)
#14 0x00000000069e1f79 clang::Sema::getNormalizedAssociatedConstraints(clang::NamedDecl*, llvm::ArrayRef<clang::Expr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69e1f79)
#15 0x00000000069f4a74 clang::Sema::IsAtLeastAsConstrained(clang::NamedDecl*, llvm::MutableArrayRef<clang::Expr const*>, clang::NamedDecl*, llvm::MutableArrayRef<clang::Expr const*>, bool&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69f4a74)
#16 0x000000000732de19 clang::ClassTemplatePartialSpecializationDecl* getMoreSpecialized<clang::ClassTemplatePartialSpecializationDecl, clang::ClassTemplateDecl>(clang::Sema&, clang::QualType, clang::QualType, clang::ClassTemplatePartialSpecializationDecl*, clang::ClassTemplateDecl*, clang::sema::TemplateDeductionInfo&) SemaTemplateDeduction.cpp:0:0
#17 0x000000000732e009 clang::Sema::isMoreSpecializedThanPrimary(clang::ClassTemplatePartialSpecializationDecl*, clang::sema::TemplateDeductionInfo&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x732e009)
#18 0x00000000072516a4 void checkTemplatePartialSpecialization<clang::ClassTemplatePartialSpecializationDecl>(clang::Sema&, clang::ClassTemplatePartialSpecializationDecl*) SemaTemplate.cpp:0:0
#19 0x00000000072e9039 clang::Sema::ActOnClassTemplateSpecialization(clang::Scope*, unsigned int, clang::TagUseKind, clang::SourceLocation, clang::SourceLocation, clang::CXXScopeSpec&, clang::TemplateIdAnnotation&, clang::ParsedAttributesView const&, llvm::MutableArrayRef<clang::TemplateParameterList*>, clang::SkipBodyInfo*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x72e9039)
#20 0x0000000006755fb3 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6755fb3)
#21 0x000000000672bb70 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x672bb70)
#22 0x00000000067f361a clang::Parser::ParseDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67f361a)
#23 0x0000000006800f3c clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (.part.0) ParseTemplate.cpp:0:0
#24 0x000000000680125a clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x680125a)
#25 0x0000000006732863 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6732863)
#26 0x00000000066f1897 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66f1897)
#27 0x00000000066f273d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66f273d)
#28 0x00000000066e4c5a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e4c5a)
#29 0x0000000004563b58 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4563b58)
#30 0x000000000481e689 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x481e689)
#31 0x000000000479d8fe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x479d8fe)
#32 0x000000000490441e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x490441e)
#33 0x0000000000ce624f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce624f)
#34 0x0000000000cddf0a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#35 0x00000000045a6cb9 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
#36 0x0000000003b35914 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b35914)
#37 0x00000000045a72af 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
#38 0x000000000456d63d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x456d63d)
#39 0x000000000456e72d 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+++0x456e72d)
#40 0x0000000004575ae5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4575ae5)
#41 0x0000000000ce30e9 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce30e9)
#42 0x0000000000bb0284 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbb0284)
#43 0x00007759bfe29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#44 0x00007759bfe29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#45 0x0000000000cdd9be _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcdd9be)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
@yijan4845 yijan4845 added c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" regression crash-on-invalid clang:frontend:fuzzer labels Nov 5, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Nov 5, 2024

@llvm/issue-subscribers-clang-frontend

Author: Yihan Yang (yijan4845)

**This testcase is generated by a fuzzer.**

Compiler Explorer: https://godbolt.org/z/P1xE1dEx1

This invalid code will crash on Clang Assertion Trunk.

template &lt;typename d&gt; concept g = 0;
template &lt;g&gt; struct h;
template &lt;g d&gt;
struct h&lt;d&gt;;

This won't crash in clang-19.

Stack dump:

clang++: /root/llvm-project/clang/lib/Sema/SemaConcept.cpp:1584: static std::optional&lt;clang::NormalizedConstraint&gt; clang::NormalizedConstraint::fromConstraintExpr(clang::Sema&amp;, clang::NamedDecl*, const clang::Expr*): Assertion `E != nullptr' 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 -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 &lt;source&gt;
1.	&lt;source&gt;:4:12: current parser token ';'
 #<!-- -->0 0x0000000003be9e28 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3be9e28)
 #<!-- -->1 0x0000000003be7b2c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3be7b2c)
 #<!-- -->2 0x0000000003b35468 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #<!-- -->3 0x00007759bfe42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->4 0x00007759bfe969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #<!-- -->5 0x00007759bfe42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #<!-- -->6 0x00007759bfe287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #<!-- -->7 0x00007759bfe2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #<!-- -->8 0x00007759bfe39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #<!-- -->9 0x00000000069e2ad0 clang::NormalizedConstraint::fromConstraintExpr(clang::Sema&amp;, clang::NamedDecl*, clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69e2ad0)
#<!-- -->10 0x00000000069e2b63 clang::NormalizedConstraint::fromConstraintExprs(clang::Sema&amp;, clang::NamedDecl*, llvm::ArrayRef&lt;clang::Expr const*&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69e2b63)
#<!-- -->11 0x00000000069e1f79 clang::Sema::getNormalizedAssociatedConstraints(clang::NamedDecl*, llvm::ArrayRef&lt;clang::Expr const*&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69e1f79)
#<!-- -->12 0x00000000069e25e3 clang::NormalizedConstraint::fromConstraintExpr(clang::Sema&amp;, clang::NamedDecl*, clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69e25e3)
#<!-- -->13 0x00000000069e2b63 clang::NormalizedConstraint::fromConstraintExprs(clang::Sema&amp;, clang::NamedDecl*, llvm::ArrayRef&lt;clang::Expr const*&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69e2b63)
#<!-- -->14 0x00000000069e1f79 clang::Sema::getNormalizedAssociatedConstraints(clang::NamedDecl*, llvm::ArrayRef&lt;clang::Expr const*&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69e1f79)
#<!-- -->15 0x00000000069f4a74 clang::Sema::IsAtLeastAsConstrained(clang::NamedDecl*, llvm::MutableArrayRef&lt;clang::Expr const*&gt;, clang::NamedDecl*, llvm::MutableArrayRef&lt;clang::Expr const*&gt;, bool&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69f4a74)
#<!-- -->16 0x000000000732de19 clang::ClassTemplatePartialSpecializationDecl* getMoreSpecialized&lt;clang::ClassTemplatePartialSpecializationDecl, clang::ClassTemplateDecl&gt;(clang::Sema&amp;, clang::QualType, clang::QualType, clang::ClassTemplatePartialSpecializationDecl*, clang::ClassTemplateDecl*, clang::sema::TemplateDeductionInfo&amp;) SemaTemplateDeduction.cpp:0:0
#<!-- -->17 0x000000000732e009 clang::Sema::isMoreSpecializedThanPrimary(clang::ClassTemplatePartialSpecializationDecl*, clang::sema::TemplateDeductionInfo&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x732e009)
#<!-- -->18 0x00000000072516a4 void checkTemplatePartialSpecialization&lt;clang::ClassTemplatePartialSpecializationDecl&gt;(clang::Sema&amp;, clang::ClassTemplatePartialSpecializationDecl*) SemaTemplate.cpp:0:0
#<!-- -->19 0x00000000072e9039 clang::Sema::ActOnClassTemplateSpecialization(clang::Scope*, unsigned int, clang::TagUseKind, clang::SourceLocation, clang::SourceLocation, clang::CXXScopeSpec&amp;, clang::TemplateIdAnnotation&amp;, clang::ParsedAttributesView const&amp;, llvm::MutableArrayRef&lt;clang::TemplateParameterList*&gt;, clang::SkipBodyInfo*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x72e9039)
#<!-- -->20 0x0000000006755fb3 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&amp;, clang::Parser::ParsedTemplateInfo&amp;, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6755fb3)
#<!-- -->21 0x000000000672bb70 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&amp;, clang::Parser::ParsedTemplateInfo&amp;, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x672bb70)
#<!-- -->22 0x00000000067f361a clang::Parser::ParseDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo&amp;, clang::ParsingDeclRAIIObject&amp;, clang::SourceLocation&amp;, clang::ParsedAttributes&amp;, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67f361a)
#<!-- -->23 0x0000000006800f3c clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&amp;, clang::ParsedAttributes&amp;, clang::AccessSpecifier) (.part.0) ParseTemplate.cpp:0:0
#<!-- -->24 0x000000000680125a clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&amp;, clang::ParsedAttributes&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x680125a)
#<!-- -->25 0x0000000006732863 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&amp;, clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6732863)
#<!-- -->26 0x00000000066f1897 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66f1897)
#<!-- -->27 0x00000000066f273d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&lt;clang::DeclGroupRef&gt;&amp;, clang::Sema::ModuleImportState&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66f273d)
#<!-- -->28 0x00000000066e4c5a clang::ParseAST(clang::Sema&amp;, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e4c5a)
#<!-- -->29 0x0000000004563b58 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4563b58)
#<!-- -->30 0x000000000481e689 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x481e689)
#<!-- -->31 0x000000000479d8fe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x479d8fe)
#<!-- -->32 0x000000000490441e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x490441e)
#<!-- -->33 0x0000000000ce624f cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce624f)
#<!-- -->34 0x0000000000cddf0a ExecuteCC1Tool(llvm::SmallVectorImpl&lt;char const*&gt;&amp;, llvm::ToolContext const&amp;) driver.cpp:0:0
#<!-- -->35 0x00000000045a6cb9 void llvm::function_ref&lt;void ()&gt;::callback_fn&lt;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::'lambda'()&gt;(long) Job.cpp:0:0
#<!-- -->36 0x0000000003b35914 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref&lt;void ()&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b35914)
#<!-- -->37 0x00000000045a72af 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 (.part.0) Job.cpp:0:0
#<!-- -->38 0x000000000456d63d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&amp;, clang::driver::Command const*&amp;, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x456d63d)
#<!-- -->39 0x000000000456e72d 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 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x456e72d)
#<!-- -->40 0x0000000004575ae5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4575ae5)
#<!-- -->41 0x0000000000ce30e9 clang_main(int, char**, llvm::ToolContext const&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce30e9)
#<!-- -->42 0x0000000000bb0284 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbb0284)
#<!-- -->43 0x00007759bfe29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#<!-- -->44 0x00007759bfe29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#<!-- -->45 0x0000000000cdd9be _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcdd9be)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134

@llvmbot
Copy link
Collaborator

llvmbot commented Nov 5, 2024

@llvm/issue-subscribers-c-20

Author: Yihan Yang (yijan4845)

**This testcase is generated by a fuzzer.**

Compiler Explorer: https://godbolt.org/z/P1xE1dEx1

This invalid code will crash on Clang Assertion Trunk.

template &lt;typename d&gt; concept g = 0;
template &lt;g&gt; struct h;
template &lt;g d&gt;
struct h&lt;d&gt;;

This won't crash in clang-19.

Stack dump:

clang++: /root/llvm-project/clang/lib/Sema/SemaConcept.cpp:1584: static std::optional&lt;clang::NormalizedConstraint&gt; clang::NormalizedConstraint::fromConstraintExpr(clang::Sema&amp;, clang::NamedDecl*, const clang::Expr*): Assertion `E != nullptr' 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 -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 &lt;source&gt;
1.	&lt;source&gt;:4:12: current parser token ';'
 #<!-- -->0 0x0000000003be9e28 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3be9e28)
 #<!-- -->1 0x0000000003be7b2c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3be7b2c)
 #<!-- -->2 0x0000000003b35468 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #<!-- -->3 0x00007759bfe42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->4 0x00007759bfe969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #<!-- -->5 0x00007759bfe42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #<!-- -->6 0x00007759bfe287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #<!-- -->7 0x00007759bfe2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #<!-- -->8 0x00007759bfe39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #<!-- -->9 0x00000000069e2ad0 clang::NormalizedConstraint::fromConstraintExpr(clang::Sema&amp;, clang::NamedDecl*, clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69e2ad0)
#<!-- -->10 0x00000000069e2b63 clang::NormalizedConstraint::fromConstraintExprs(clang::Sema&amp;, clang::NamedDecl*, llvm::ArrayRef&lt;clang::Expr const*&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69e2b63)
#<!-- -->11 0x00000000069e1f79 clang::Sema::getNormalizedAssociatedConstraints(clang::NamedDecl*, llvm::ArrayRef&lt;clang::Expr const*&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69e1f79)
#<!-- -->12 0x00000000069e25e3 clang::NormalizedConstraint::fromConstraintExpr(clang::Sema&amp;, clang::NamedDecl*, clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69e25e3)
#<!-- -->13 0x00000000069e2b63 clang::NormalizedConstraint::fromConstraintExprs(clang::Sema&amp;, clang::NamedDecl*, llvm::ArrayRef&lt;clang::Expr const*&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69e2b63)
#<!-- -->14 0x00000000069e1f79 clang::Sema::getNormalizedAssociatedConstraints(clang::NamedDecl*, llvm::ArrayRef&lt;clang::Expr const*&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69e1f79)
#<!-- -->15 0x00000000069f4a74 clang::Sema::IsAtLeastAsConstrained(clang::NamedDecl*, llvm::MutableArrayRef&lt;clang::Expr const*&gt;, clang::NamedDecl*, llvm::MutableArrayRef&lt;clang::Expr const*&gt;, bool&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69f4a74)
#<!-- -->16 0x000000000732de19 clang::ClassTemplatePartialSpecializationDecl* getMoreSpecialized&lt;clang::ClassTemplatePartialSpecializationDecl, clang::ClassTemplateDecl&gt;(clang::Sema&amp;, clang::QualType, clang::QualType, clang::ClassTemplatePartialSpecializationDecl*, clang::ClassTemplateDecl*, clang::sema::TemplateDeductionInfo&amp;) SemaTemplateDeduction.cpp:0:0
#<!-- -->17 0x000000000732e009 clang::Sema::isMoreSpecializedThanPrimary(clang::ClassTemplatePartialSpecializationDecl*, clang::sema::TemplateDeductionInfo&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x732e009)
#<!-- -->18 0x00000000072516a4 void checkTemplatePartialSpecialization&lt;clang::ClassTemplatePartialSpecializationDecl&gt;(clang::Sema&amp;, clang::ClassTemplatePartialSpecializationDecl*) SemaTemplate.cpp:0:0
#<!-- -->19 0x00000000072e9039 clang::Sema::ActOnClassTemplateSpecialization(clang::Scope*, unsigned int, clang::TagUseKind, clang::SourceLocation, clang::SourceLocation, clang::CXXScopeSpec&amp;, clang::TemplateIdAnnotation&amp;, clang::ParsedAttributesView const&amp;, llvm::MutableArrayRef&lt;clang::TemplateParameterList*&gt;, clang::SkipBodyInfo*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x72e9039)
#<!-- -->20 0x0000000006755fb3 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&amp;, clang::Parser::ParsedTemplateInfo&amp;, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6755fb3)
#<!-- -->21 0x000000000672bb70 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&amp;, clang::Parser::ParsedTemplateInfo&amp;, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x672bb70)
#<!-- -->22 0x00000000067f361a clang::Parser::ParseDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo&amp;, clang::ParsingDeclRAIIObject&amp;, clang::SourceLocation&amp;, clang::ParsedAttributes&amp;, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67f361a)
#<!-- -->23 0x0000000006800f3c clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&amp;, clang::ParsedAttributes&amp;, clang::AccessSpecifier) (.part.0) ParseTemplate.cpp:0:0
#<!-- -->24 0x000000000680125a clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&amp;, clang::ParsedAttributes&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x680125a)
#<!-- -->25 0x0000000006732863 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&amp;, clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6732863)
#<!-- -->26 0x00000000066f1897 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66f1897)
#<!-- -->27 0x00000000066f273d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&lt;clang::DeclGroupRef&gt;&amp;, clang::Sema::ModuleImportState&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66f273d)
#<!-- -->28 0x00000000066e4c5a clang::ParseAST(clang::Sema&amp;, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e4c5a)
#<!-- -->29 0x0000000004563b58 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4563b58)
#<!-- -->30 0x000000000481e689 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x481e689)
#<!-- -->31 0x000000000479d8fe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x479d8fe)
#<!-- -->32 0x000000000490441e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x490441e)
#<!-- -->33 0x0000000000ce624f cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce624f)
#<!-- -->34 0x0000000000cddf0a ExecuteCC1Tool(llvm::SmallVectorImpl&lt;char const*&gt;&amp;, llvm::ToolContext const&amp;) driver.cpp:0:0
#<!-- -->35 0x00000000045a6cb9 void llvm::function_ref&lt;void ()&gt;::callback_fn&lt;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::'lambda'()&gt;(long) Job.cpp:0:0
#<!-- -->36 0x0000000003b35914 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref&lt;void ()&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b35914)
#<!-- -->37 0x00000000045a72af 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 (.part.0) Job.cpp:0:0
#<!-- -->38 0x000000000456d63d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&amp;, clang::driver::Command const*&amp;, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x456d63d)
#<!-- -->39 0x000000000456e72d 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 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x456e72d)
#<!-- -->40 0x0000000004575ae5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4575ae5)
#<!-- -->41 0x0000000000ce30e9 clang_main(int, char**, llvm::ToolContext const&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce30e9)
#<!-- -->42 0x0000000000bb0284 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbb0284)
#<!-- -->43 0x00007759bfe29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#<!-- -->44 0x00007759bfe29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#<!-- -->45 0x0000000000cdd9be _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcdd9be)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++20 clang:frontend:fuzzer clang:frontend Language frontend issues, e.g. anything involving "Sema" crash-on-invalid regression
Projects
None yet
Development

No branches or pull requests

2 participants