Skip to content

[Clang][C++20] LLVM ERROR: out of memory allocating string in diagnoseWellFormedUnsatisfiedConstraintExpr #64172

Closed
@widberg

Description

@widberg

When compiling the following ill-formed C++20 code some diagnostics are printed followed by the crash dump.

godbolt

clang++-16 -std=c++20 clang-ice-DiagnoseUnsatisfiedConstraint.cpp
template <typename>
__boolean_testable_impl;

template <typename _Tp>
concept __boolean_testable = __boolean_testable_impl<_Tp>;

template <typename, typename _Up>
concept __partially_ordered_with = requires(_Up __u)
{
  {
    __u
  }

  __boolean_testable;
};

template <typename _Tp, typename>
concept three_way_comparable = __partially_ordered_with<_Tp, _Tp>;

template <typename _Up, typename _Cat>
concept three_way_comparable_with = three_way_comparable<_Up, _Cat>;
struct compare_three_way
{
  template <typename _Tp, typename _Up>
    requires three_way_comparable_with<_Tp, _Up>
  auto operator()(_Tp, _Up);
  class error_category
  {
    void strong_ordering(error_category __rhs)
    {
      compare_three_way()(this, __rhs)
    }
  };
};
LLVM ERROR: out of memory
Allocation 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: /usr/lib/llvm-16/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name clang-ice-DiagnoseUnsatisfiedConstraint.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 -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/home/user/share -resource-dir /usr/lib/llvm-16/lib/clang/16 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../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++20 -fdeprecated-macro -fdebug-compilation-dir=/home/user/share -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/clang-ice-DiagnoseUnsatisfiedConstraint-397582.o -x c++ clang-ice-DiagnoseUnsatisfiedConstraint.cpp
1.	clang-ice-DiagnoseUnsatisfiedConstraint.cpp:14:38: current parser token ')'
2.	clang-ice-DiagnoseUnsatisfiedConstraint.cpp:12:41: parsing struct/union/class body 'compare_three_way'
3.	clang-ice-DiagnoseUnsatisfiedConstraint.cpp:13:49: parsing function body 'compare_three_way::error_category::publicstrong_ordering'
4.	clang-ice-DiagnoseUnsatisfiedConstraint.cpp:13:49: in compound statement ('{}')
 #0 0x00007fffed94eb96 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-16/bin/../lib/libLLVM-16.so.1+0xfbeb96)
 #1 0x00007fffed94cd20 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-16/bin/../lib/libLLVM-16.so.1+0xfbcd20)
 #2 0x00007fffed94f370 (/usr/lib/llvm-16/bin/../lib/libLLVM-16.so.1+0xfbf370)
 #3 0x00007ffff7bc6980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #4 0x00007fffebc1be87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007fffebc1d7f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007fffed89ab98 llvm::report_bad_alloc_error(char const*, bool) (/usr/lib/llvm-16/bin/../lib/libLLVM-16.so.1+0xf0ab98)
 #7 0x00007fffed89abd2 (/usr/lib/llvm-16/bin/../lib/libLLVM-16.so.1+0xf0abd2)
 #8 0x00007fffec5e263f operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0xb263f)
 #9 0x00007ffff4a351b7 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xaa51b7)
#10 0x00007ffff5262f3a (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x12d2f3a)
#11 0x00007ffff54225a7 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x14925a7)
#12 0x00007ffff5421d3f (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1491d3f)
#13 0x00007ffff5421d3f (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1491d3f)
#14 0x00007ffff5421d3f (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1491d3f)
#15 0x00007ffff53f68bc clang::Sema::DiagnoseUnsatisfiedConstraint(clang::ConstraintSatisfaction const&, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x14668bc)
#16 0x00007ffff58558a8 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x18c58a8)
#17 0x00007ffff5840039 clang::OverloadCandidateSet::NoteCandidates(clang::Sema&, llvm::ArrayRef<clang::Expr*>, llvm::ArrayRef<clang::OverloadCandidate*>, llvm::StringRef, clang::SourceLocation) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x18b0039)
#18 0x00007ffff5854e75 clang::OverloadCandidateSet::NoteCandidates(std::pair<clang::SourceLocation, clang::PartialDiagnostic>, clang::Sema&, clang::OverloadCandidateDisplayKind, llvm::ArrayRef<clang::Expr*>, llvm::StringRef, clang::SourceLocation, llvm::function_ref<bool (clang::OverloadCandidate&)>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x18c4e75)
#19 0x00007ffff5862113 clang::Sema::BuildCallToObjectOfClassType(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x18d2113)
#20 0x00007ffff557b6f1 clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x15eb6f1)
#21 0x00007ffff559382d clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x160382d)
#22 0x00007ffff4ba3a8c clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc13a8c)
#23 0x00007ffff4ba49a5 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc149a5)
#24 0x00007ffff4ba0c21 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc10c21)
#25 0x00007ffff4ba0af9 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc10af9)
#26 0x00007ffff4bfffa5 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc6ffa5)
#27 0x00007ffff4bfe4c4 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc6e4c4)
#28 0x00007ffff4bfde7d clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc6de7d)
#29 0x00007ffff4c06310 clang::Parser::ParseCompoundStatementBody(bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc76310)
#30 0x00007ffff4c073cf clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc773cf)
#31 0x00007ffff4b61ff1 clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xbd1ff1)
#32 0x00007ffff4b60cfa clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xbd0cfa)
#33 0x00007ffff4b60cfa clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xbd0cfa)
#34 0x00007ffff4b949e9 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc049e9)
#35 0x00007ffff4b92296 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc02296)
#36 0x00007ffff4b74661 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xbe4661)
#37 0x00007ffff4c20320 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc90320)
#38 0x00007ffff4c20089 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc90089)
#39 0x00007ffff4c1f327 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc8f327)
#40 0x00007ffff4c1d6ce clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc8d6ce)
#41 0x00007ffff4b5d39e clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xbcd39e)
#42 0x00007ffff6778165 clang::FrontendAction::Execute() (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x27e8165)
#43 0x00007ffff66f50e4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x27650e4)
#44 0x00007ffff67f0b44 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x2860b44)
#45 0x0000555555568f5e cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-16/bin/clang+0x14f5e)
#46 0x0000555555566210 (/usr/lib/llvm-16/bin/clang+0x12210)
#47 0x0000555555565e49 clang_main(int, char**) (/usr/lib/llvm-16/bin/clang+0x11e49)
#48 0x00007fffebbfec87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#49 0x000055555556287a _start (/usr/lib/llvm-16/bin/clang+0xe87a)
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 16.0.6 (++20230710041619+7cbf1a259152-1~exp1~20230710161636.103)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzercrashPrefer [crash-on-valid] or [crash-on-invalid]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions