llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.59k stars 11.34k forks source link

"Multiple diagnostics in flight at once!" assert, and runaway memory usage in release builds, on C++20 testcase with PCH #70930

Open coreyzzp opened 9 months ago

coreyzzp commented 9 months ago

version : llvmorg-17.0.3

Recently, when using clangd in vscode remote, once a certain file is encountered, the memory will explode, eventually causing the entire machine to go out of memory (clangd consumes more than 64G of memory). Below is the stack (using the release version, compiled with -g)

#0  0x00007f4d2d1a8233 in _int_malloc () from /lib64/libc.so.6
#1  0x00007f4d2d1ab10c in malloc () from /lib64/libc.so.6
#2  0x0000000000a2b2d8 in llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long) ()
#3  0x0000000000f35070 in llvm::SmallVectorTemplateCommon<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, void>::grow_pod (TSize=16, MinSize=<optimized out>, this=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:140
#4  llvm::SmallVectorTemplateBase<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, true>::grow (MinSize=<optimized out>, this=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:529
#5  llvm::SmallVectorTemplateCommon<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, void>::reserveForParamAndGetAddressImpl<llvm::SmallVectorTemplateBase<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, true> > (N=1, Elt=<synthetic pointer>..., This=0x7f4d25fe3710)
    at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:246
#6  llvm::SmallVectorTemplateBase<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, true>::reserveForParamAndGetAddress (N=1, Elt=<synthetic pointer>..., this=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:541
#7  llvm::SmallVectorTemplateBase<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, true>::push_back (Elt=..., this=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:566
#8  clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a4068 <(anonymous namespace)::StaticDiagInfoDescriptions+249544> "'", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1142
#9  0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#10 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a3d23 <(anonymous namespace)::StaticDiagInfoDescriptions+248707> ")' clause%select{s|}1", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#11 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#12 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a3cf0 <(anonymous namespace)::StaticDiagInfoDescriptions+248656> " cannot be mixed with '%0(%select{sink:vec|source}1)' clause%select{s|}1", DiagEnd=<optimized out>, OutStr=...)
    at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#13 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#14 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a3cdb <(anonymous namespace)::StaticDiagInfoDescriptions+248635> ")' clause%select{|s}1 cannot be mixed with '%0(%select{sink:vec|source}1)' clause%select{s|}1", DiagEnd=<optimized out>, OutStr=...)
    at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#15 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#16 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a2e66 <(anonymous namespace)::StaticDiagInfoDescriptions+244934> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#17 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#18 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a138a <(anonymous namespace)::StaticDiagInfoDescriptions+238058> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#19 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#20 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a08f0 <(anonymous namespace)::StaticDiagInfoDescriptions+235344> " type", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#21 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#22 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69fb28 <(anonymous namespace)::StaticDiagInfoDescriptions+231816> ", not %0", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#23 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#24 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69f1b4 <(anonymous namespace)::StaticDiagInfoDescriptions+229396> " because assigning method's 2nd parameter of type %0 is not an Objective-C pointer type", DiagEnd=<optimized out>, OutStr=...)
    at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#25 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#26 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69ea67 <(anonymous namespace)::StaticDiagInfoDescriptions+227527> " element must have Objective-C object return type instead of %0", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#27 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#28 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69e6bf <(anonymous namespace)::StaticDiagInfoDescriptions+226591> " %3", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#29 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#30 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69e660 <(anonymous namespace)::StaticDiagInfoDescriptions+226496> " declaration conflicts with previous %select{|direct }2declaration of %select{method|property}1 %3", DiagEnd=<optimized out>, OutStr=...)
    at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#31 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#32 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69e3eb <(anonymous namespace)::StaticDiagInfoDescriptions+225867> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#33 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#34 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69c9ab <(anonymous namespace)::StaticDiagInfoDescriptions+219147> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#35 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#36 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69bde6 <(anonymous namespace)::StaticDiagInfoDescriptions+216134> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#37 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#38 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69b4bd <(anonymous namespace)::StaticDiagInfoDescriptions+213789> " follows declaration in %select{the global module|module %4}3", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#39 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#40 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69b239 <(anonymous namespace)::StaticDiagInfoDescriptions+213145> " method %0 not found ; did you mean %2?", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#41 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#42 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69ad1b <(anonymous namespace)::StaticDiagInfoDescriptions+211835> ", but function has %select{non-const lvalue|rvalue}2 ref-qualifier", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#43 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#44 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69aa5c <(anonymous namespace)::StaticDiagInfoDescriptions+211132> " %2?", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#45 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#46 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69a6ec <(anonymous namespace)::StaticDiagInfoDescriptions+210252> " integers and enum types, but was given %2%select{| whose underlying type is %4}3", DiagEnd=<optimized out>, OutStr=...)
    at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
   .......
   .......
   ....... something like FormatDiagnostic
   .......
   .......
   .......
   .......
#224 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67f46c <(anonymous namespace)::StaticDiagInfoDescriptions+99020> " found %select{%select{no super class|super class with type %5}4|instance variable '%4' access control is %select{|@private|@protected|@public|@package}5}3",
    DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#225 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#226 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930,
    DiagStr=0x67f30c <(anonymous namespace)::StaticDiagInfoDescriptions+98668> " has different definitions in different modules; first difference is this %select{||||static assert|field|method|type alias|typedef|data member|friend declaration|function template|method|instance var"..., DiagEnd=<optimized out>,
    OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#227 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#228 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930,
    DiagStr=0x67f1e8 <(anonymous namespace)::StaticDiagInfoDescriptions+98376> " found %select{end of class|public access specifier|private access specifier|protected access specifier|static assert|field|method|type alias|typedef|data member|friend declaration|function template|m"..., DiagEnd=<optimized out>,
    OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#229 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#230 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930,
    DiagStr=0x67f064 <(anonymous namespace)::StaticDiagInfoDescriptions+97988> " found %select{%select{method %5|constructor|destructor}4 that has %6 parameter%s6|%select{method %5|constructor|destructor}4 with %ordinal6 parameter of type %7%select{| decayed from %9}8|%select{met"..., DiagEnd=<optimized out>,
    OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#231 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628
#232 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930,
    DiagStr=0x67eeea <(anonymous namespace)::StaticDiagInfoDescriptions+97610> " first difference is %select{return type is %4|%ordinal4 parameter with name %5|%ordinal4 parameter with type %5%select{| decayed from %7}6|%ordinal4 parameter with%select{out|}5 a default argument|%o"..., DiagEnd=<optimized out>,
    OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001
#233 0x0000000001de8f76 in clang::clangd::fillNonLocationData (DiagLevel=clang::DiagnosticsEngine::Error, Info=..., D=...) at /llvmorg-17.0.3/clang-tools-extra/clangd/Diagnostics.cpp:664
#234 0x0000000001dea974 in operator() (__closure=__closure@entry=0x7f4d25ff66e0, D=...) at /llvmorg-17.0.3/clang-tools-extra/clangd/Diagnostics.cpp:720
#235 0x0000000001df8222 in clang::clangd::StoreDiags::HandleDiagnostic (this=0x7f4d25ff9be0, DiagLevel=<optimized out>, Info=...) at /opt/gcc-11.1.0/include/c++/11.1.0/optional:440
#236 0x0000000000f3a572 in clang::DiagnosticIDs::EmitDiag (DiagLevel=clang::DiagnosticIDs::Error, Diag=..., this=0x7f4d1c01e1f0) at /llvmorg-17.0.3/clang/lib/Basic/DiagnosticIDs.cpp:823
#237 clang::DiagnosticIDs::ProcessDiag (this=this@entry=0x7f4d1c01e1f0, Diag=...) at /llvmorg-17.0.3/clang/lib/Basic/DiagnosticIDs.cpp:815
#238 0x0000000000f33f1b in clang::DiagnosticsEngine::ProcessDiag (this=0x7f4d1c001990) at /llvmorg-17.0.3/clang/include/clang/Basic/Diagnostic.h:1037
#239 clang::DiagnosticsEngine::EmitCurrentDiagnostic (this=0x7f4d1c001990, Force=<optimized out>) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:545
#240 0x0000000000b61590 in clang::DiagnosticBuilder::~DiagnosticBuilder() ()
#241 0x0000000000e0f1f4 in clang::ODRDiagsEmitter::diagnoseMismatch(clang::FunctionDecl const*, clang::FunctionDecl const*) const ()
#242 0x0000000002b5b877 in clang::ASTReader::diagnoseOdrViolations() [clone .localalias] ()
#243 0x0000000002b5e761 in clang::ASTReader::FinishedDeserializing() [clone .part.0] ()
#244 0x0000000002bbac65 in clang::ASTReader::ReadDeclRecord(unsigned int) ()
#245 0x0000000002b4d6c9 in clang::ASTReader::GetDecl(unsigned int) [clone .localalias] ()
#246 0x0000000002b665c3 in clang::ASTReader::completeVisibleDeclsMap(clang::DeclContext const*) [clone .part.0] ()
#247 0x00000000018c2e1e in (anonymous namespace)::LookupVisibleHelper::lookupInDeclContext(clang::DeclContext*, clang::LookupResult&, bool, bool) ()
#248 0x00000000018c5282 in clang::Sema::LookupVisibleDecls(clang::DeclContext*, clang::Sema::LookupNameKind, clang::VisibleDeclConsumer&, bool, bool, bool) [clone .localalias] ()
#249 0x00000000018cf4f4 in clang::Sema::makeTypoCorrectionConsumer(clang::DeclarationNameInfo const&, clang::Sema::LookupNameKind, clang::Scope*, clang::CXXScopeSpec*, clang::CorrectionCandidateCallback&, clang::DeclContext*, bool, clang::ObjCObjectPointerType const*, bool) [clone .localalias] ()
#250 0x00000000018d0c1d in clang::Sema::CorrectTypo(clang::DeclarationNameInfo const&, clang::Sema::LookupNameKind, clang::Scope*, clang::CXXScopeSpec*, clang::CorrectionCandidateCallback&, clang::Sema::CorrectTypoKind, clang::DeclContext*, bool, clang::ObjCObjectPointerType const*, bool) ()
#251 0x0000000001536b02 in clang::Sema::DiagnoseUnknownTypeName(clang::IdentifierInfo*&, clang::SourceLocation, clang::Scope*, clang::CXXScopeSpec*, clang::OpaquePtr<clang::QualType>&, bool) ()
#252 0x0000000002a1a27d in clang::Parser::ParseImplicitInt(clang::DeclSpec&, clang::CXXScopeSpec*, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) [clone .localalias] ()
#253 0x0000000002a1e49c in clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) [clone .localalias] ()
#254 0x0000000002af8dad in clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) [clone .localalias] ()
#255 0x0000000002af9e9f in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) [clone .part.0] ()
#256 0x0000000002b00676 in clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) [clone .localalias] ()
#257 0x0000000002b018da in clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) [clone .localalias] ()
#258 0x00000000029fe3ca in clang::ParseAST(clang::Sema&, bool, bool) [clone .localalias] ()
#259 0x000000000116f5f9 in clang::FrontendAction::Execute() ()
#260 0x0000000001ee75fd in clang::clangd::ParsedAST::build (Filename=..., Inputs=..., CI=..., CompilerInvocationDiags=..., Preamble=...) at /llvmorg-17.0.3/clang-tools-extra/clangd/ParsedAST.cpp:669
#261 0x0000000001f5d462 in clang::clangd::(anonymous namespace)::ASTWorker::generateDiagnostics (this=0x3946950, Invocation=..., Inputs=..., CIDiags=...) at /opt/gcc-11.1.0/include/c++/11.1.0/bits/basic_string.h:912
#262 0x0000000001f5dd83 in operator() (__closure=0x7f4cf80022d0) at /opt/gcc-11.1.0/include/c++/11.1.0/bits/unique_ptr.h:172
#263 0x0000000001f56965 in llvm::unique_function<void ()>::operator()() (this=0x3946bb0) at /llvmorg-17.0.3/llvm/include/llvm/ADT/FunctionExtras.h:382
#264 llvm::function_ref<void ()>::callback_fn<llvm::unique_function<void ()> >(long) (callable=60058544) at /llvmorg-17.0.3/llvm/include/llvm/ADT/STLFunctionalExtras.h:45
#265 llvm::function_ref<void ()>::operator()() const (this=<synthetic pointer>) at /llvmorg-17.0.3/llvm/include/llvm/ADT/STLFunctionalExtras.h:68
#266 clang::clangd::(anonymous namespace)::ASTWorker::runTask(llvm::StringRef, llvm::function_ref<void()>) (this=this@entry=0x3946950, Name=..., Task=...) at /llvmorg-17.0.3/clang-tools-extra/clangd/TUScheduler.cpp:1324
#267 0x0000000001f58439 in clang::clangd::(anonymous namespace)::ASTWorker::run (this=0x3946950) at /llvmorg-17.0.3/clang-tools-extra/clangd/TUScheduler.cpp:1458
#268 0x0000000002106f25 in llvm::unique_function<void ()>::operator()() (this=0x392abc0) at /llvmorg-17.0.3/llvm/include/llvm/ADT/FunctionExtras.h:382
#269 operator() (__closure=0x392aba0) at /llvmorg-17.0.3/clang-tools-extra/clangd/support/Threading.cpp:101
#270 operator()<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()>&> (F=..., __closure=<optimized out>) at /llvmorg-17.0.3/llvm/include/llvm/Support/thread.h:43
#271 std::__invoke_impl<void, llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()>&> (__f=...) at /opt/gcc-11.1.0/include/c++/11.1.0/bits/invoke.h:61
#272 std::__invoke<llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()>&> (__fn=...) at /opt/gcc-11.1.0/include/c++/11.1.0/bits/invoke.h:96
#273 std::__apply_impl<llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> >&, 0> (__t=..., __f=...) at /opt/gcc-11.1.0/include/c++/11.1.0/tuple:1806
#274 std::apply<llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> >&> (__t=..., __f=...) at /opt/gcc-11.1.0/include/c++/11.1.0/tuple:1817
#275 llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > > (Ptr=0x392aba0) at /llvmorg-17.0.3/llvm/include/llvm/Support/thread.h:41
#276 llvm::thread::ThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void *) (Ptr=0x392aba0) at /llvmorg-17.0.3/llvm/include/llvm/Support/thread.h:55
#277 0x00007f4d2e258e25 in start_thread () from /lib64/libpthread.so.0
#278 0x00007f4d2d22335d in clone () from /lib64/libc.so.6

the input to clang::Diagnostic::FormatDiagnostic look like this:

 f 232
#232 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930,
    DiagStr=0x67eeea <(anonymous namespace)::StaticDiagInfoDescriptions+97610> " first difference is %select{return type is %4|%ordinal4 parameter with name %5|%ordinal4 parameter with type %5%select{| decayed from %7}6|%ordinal4 parameter with%select{out|}5 a default argument|%o"..., DiagEnd=<optimized out>,
    OutStr=...) at /source/install/llvm/llvm.git/clang/lib/Basic/Diagnostic.cpp:1001
1001            HandleSelectModifier(*this, Val, Argument, ArgumentLen, OutStr);
(gdb) p DiagStr
$5 = 0x67eeea <(anonymous namespace)::StaticDiagInfoDescriptions+97610> " first difference is %select{return type is %4|%ordinal4 parameter with name %5|%ordinal4 parameter with type %5%select{| decayed from %7}6|%ordinal4 parameter with%select{out|}5 a default argument|%o"...
(gdb) printf "%s\n", DiagStr
 first difference is %select{return type is %4|%ordinal4 parameter with name %5|%ordinal4 parameter with type %5%select{| decayed from %7}6|%ordinal4 parameter with%select{out|}5 a default argument|%ordinal4 parameter with a default argument|function body}3
(gdb)

and the OutStr contains the hugh memory

(gdb) p OutStr
$24 = (llvm::SmallVectorImpl<char> &) @0x7f4d25ff6500: {
  <llvm::SmallVectorTemplateBase<char, true>> = {
    <llvm::SmallVectorTemplateCommon<char, void>> = {
      <llvm::SmallVectorBase<unsigned long>> = {
        BeginX = 0x7f48d43fa010,
        Size = 4511505832,
        Capacity = 8724152319
      }, <No data fields>},
    members of llvm::SmallVectorTemplateBase<char, true>:
    static TakesParamByValue = true
  }, <No data fields>}
(gdb)

the content of OutStr

(gdb) x /20xs (0x7f48d43fa010)
0x7f48d43fa010: "'std::midpoint' has different definitions in different modules; 1 first difference is '_Tp'"
0x7f48d43fa06c: " has different definitions in different modules; first difference is 1 found '_Tp'"
0x7f48d43fa0bf: " has different definitions in different modules; first difference is 1 found '_Tp'"
0x7f48d43fa112: " 1 has different definitions in different modules; first difference is this '_Tp'"
0x7f48d43fa164: " has different definitions in different modules; first difference is 1 found '_Tp'"
0x7f48d43fa1b7: " has different definitions in different modules; first difference is 1 found '_Tp'"
0x7f48d43fa20a: " has different definitions in different modules; first difference is 1 found '_Tp'"
0x7f48d43fa25d: " has different definitions in different modules; first difference is 1 found '_Tp'"
0x7f48d43fa2b0: " has different definitions in different modules; first difference is 1 found '_Tp'"
0x7f48d43fa303: " has different definitions in different modules; first difference is 1 found '_Tp'"
0x7f48d43fa356: " has different definitions in different modules; first difference is 1 found '_Tp'"
0x7f48d43fa3a9: " has different definitions in different modules; first difference is 1 found '_Tp'"
0x7f48d43fa3fc: "template parameter lists have a different number of parameters ( vs 2)"
0x7f48d43fa443: "template parameter has different kinds in different translation units"
0x7f48d43fa489: "field  declared with incompatible types in different translation units (2 vs. 1)"
0x7f48d43fa4da: "external function  declared with incompatible types in different translation units (2 vs. 1)"
0x7f48d43fa537: "instance variable  declared with incompatible types in different translation units (2 vs. 1)"
0x7f48d43fa594: "non-type template parameter declared with incompatible types in different translation units ( vs. 2)"
0x7f48d43fa5f9: " method 2 has a different number of parameters in different translation units (1 vs. '_Tp')"
0x7f48d43fa655: " method 2 has a parameter with a different types in different translation units (1 vs. '_Tp')"

(gdb) x /20xs (0x7f48d43fa010 + 4511505832 - 200)
0x7f49e127bcf0: "ncurrent"
0x7f49e127bcf9: "expected  in OpenMP clause '2'"
0x7f49e127bd18: "modifier '' cannot be used along with modifier '2'"
0x7f49e127bd4b: "mapping of union members is not allowed"
0x7f49e127bd73: "incorrect reduction identifier, expected one of '+', '-', '*', '&', '"
0x7f49e127bdb9: ""
0x7f49e127bdba: ""
0x7f49e127bdbb: ""
0x7f49e127bdbc: ""
0x7f49e127bdbd: ""
0x7f49e127bdbe: ""
llvmbot commented 9 months ago

@llvm/issue-subscribers-clangd

Author: ZHU ZHIPU (coreyzzp)

version : llvmorg-17.0.3 Recently, when using clangd in vscode remote, once a certain file is encountered, the memory will explode, eventually causing the entire machine to go out of memory (clangd consumes more than 64G of memory). Below is the stack (using the release version, compiled with -g) ``` #0 0x00007f4d2d1a8233 in _int_malloc () from /lib64/libc.so.6 #1 0x00007f4d2d1ab10c in malloc () from /lib64/libc.so.6 #2 0x0000000000a2b2d8 in llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long) () #3 0x0000000000f35070 in llvm::SmallVectorTemplateCommon<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, void>::grow_pod (TSize=16, MinSize=<optimized out>, this=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:140 #4 llvm::SmallVectorTemplateBase<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, true>::grow (MinSize=<optimized out>, this=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:529 #5 llvm::SmallVectorTemplateCommon<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, void>::reserveForParamAndGetAddressImpl<llvm::SmallVectorTemplateBase<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, true> > (N=1, Elt=<synthetic pointer>..., This=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:246 #6 llvm::SmallVectorTemplateBase<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, true>::reserveForParamAndGetAddress (N=1, Elt=<synthetic pointer>..., this=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:541 #7 llvm::SmallVectorTemplateBase<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, true>::push_back (Elt=..., this=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:566 #8 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a4068 <(anonymous namespace)::StaticDiagInfoDescriptions+249544> "'", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1142 #9 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #10 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a3d23 <(anonymous namespace)::StaticDiagInfoDescriptions+248707> ")' clause%select{s|}1", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #11 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #12 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a3cf0 <(anonymous namespace)::StaticDiagInfoDescriptions+248656> " cannot be mixed with '%0(%select{sink:vec|source}1)' clause%select{s|}1", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #13 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #14 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a3cdb <(anonymous namespace)::StaticDiagInfoDescriptions+248635> ")' clause%select{|s}1 cannot be mixed with '%0(%select{sink:vec|source}1)' clause%select{s|}1", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #15 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #16 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a2e66 <(anonymous namespace)::StaticDiagInfoDescriptions+244934> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #17 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #18 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a138a <(anonymous namespace)::StaticDiagInfoDescriptions+238058> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #19 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #20 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a08f0 <(anonymous namespace)::StaticDiagInfoDescriptions+235344> " type", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #21 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #22 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69fb28 <(anonymous namespace)::StaticDiagInfoDescriptions+231816> ", not %0", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #23 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #24 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69f1b4 <(anonymous namespace)::StaticDiagInfoDescriptions+229396> " because assigning method's 2nd parameter of type %0 is not an Objective-C pointer type", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #25 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #26 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69ea67 <(anonymous namespace)::StaticDiagInfoDescriptions+227527> " element must have Objective-C object return type instead of %0", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #27 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #28 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69e6bf <(anonymous namespace)::StaticDiagInfoDescriptions+226591> " %3", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #29 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #30 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69e660 <(anonymous namespace)::StaticDiagInfoDescriptions+226496> " declaration conflicts with previous %select{|direct }2declaration of %select{method|property}1 %3", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #31 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #32 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69e3eb <(anonymous namespace)::StaticDiagInfoDescriptions+225867> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #33 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #34 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69c9ab <(anonymous namespace)::StaticDiagInfoDescriptions+219147> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #35 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #36 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69bde6 <(anonymous namespace)::StaticDiagInfoDescriptions+216134> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #37 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #38 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69b4bd <(anonymous namespace)::StaticDiagInfoDescriptions+213789> " follows declaration in %select{the global module|module %4}3", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #39 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #40 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69b239 <(anonymous namespace)::StaticDiagInfoDescriptions+213145> " method %0 not found ; did you mean %2?", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #41 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #42 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69ad1b <(anonymous namespace)::StaticDiagInfoDescriptions+211835> ", but function has %select{non-const lvalue|rvalue}2 ref-qualifier", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #43 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #44 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69aa5c <(anonymous namespace)::StaticDiagInfoDescriptions+211132> " %2?", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #45 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #46 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69a6ec <(anonymous namespace)::StaticDiagInfoDescriptions+210252> " integers and enum types, but was given %2%select{| whose underlying type is %4}3", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 ....... ....... ....... something like FormatDiagnostic ....... ....... ....... ....... #224 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67f46c <(anonymous namespace)::StaticDiagInfoDescriptions+99020> " found %select{%select{no super class|super class with type %5}4|instance variable '%4' access control is %select{|@private|@protected|@public|@package}5}3", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #225 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #226 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67f30c <(anonymous namespace)::StaticDiagInfoDescriptions+98668> " has different definitions in different modules; first difference is this %select{||||static assert|field|method|type alias|typedef|data member|friend declaration|function template|method|instance var"..., DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #227 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #228 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67f1e8 <(anonymous namespace)::StaticDiagInfoDescriptions+98376> " found %select{end of class|public access specifier|private access specifier|protected access specifier|static assert|field|method|type alias|typedef|data member|friend declaration|function template|m"..., DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #229 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #230 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67f064 <(anonymous namespace)::StaticDiagInfoDescriptions+97988> " found %select{%select{method %5|constructor|destructor}4 that has %6 parameter%s6|%select{method %5|constructor|destructor}4 with %ordinal6 parameter of type %7%select{| decayed from %9}8|%select{met"..., DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #231 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #232 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67eeea <(anonymous namespace)::StaticDiagInfoDescriptions+97610> " first difference is %select{return type is %4|%ordinal4 parameter with name %5|%ordinal4 parameter with type %5%select{| decayed from %7}6|%ordinal4 parameter with%select{out|}5 a default argument|%o"..., DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #233 0x0000000001de8f76 in clang::clangd::fillNonLocationData (DiagLevel=clang::DiagnosticsEngine::Error, Info=..., D=...) at /llvmorg-17.0.3/clang-tools-extra/clangd/Diagnostics.cpp:664 #234 0x0000000001dea974 in operator() (__closure=__closure@entry=0x7f4d25ff66e0, D=...) at /llvmorg-17.0.3/clang-tools-extra/clangd/Diagnostics.cpp:720 #235 0x0000000001df8222 in clang::clangd::StoreDiags::HandleDiagnostic (this=0x7f4d25ff9be0, DiagLevel=<optimized out>, Info=...) at /opt/gcc-11.1.0/include/c++/11.1.0/optional:440 #236 0x0000000000f3a572 in clang::DiagnosticIDs::EmitDiag (DiagLevel=clang::DiagnosticIDs::Error, Diag=..., this=0x7f4d1c01e1f0) at /llvmorg-17.0.3/clang/lib/Basic/DiagnosticIDs.cpp:823 #237 clang::DiagnosticIDs::ProcessDiag (this=this@entry=0x7f4d1c01e1f0, Diag=...) at /llvmorg-17.0.3/clang/lib/Basic/DiagnosticIDs.cpp:815 #238 0x0000000000f33f1b in clang::DiagnosticsEngine::ProcessDiag (this=0x7f4d1c001990) at /llvmorg-17.0.3/clang/include/clang/Basic/Diagnostic.h:1037 #239 clang::DiagnosticsEngine::EmitCurrentDiagnostic (this=0x7f4d1c001990, Force=<optimized out>) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:545 #240 0x0000000000b61590 in clang::DiagnosticBuilder::~DiagnosticBuilder() () #241 0x0000000000e0f1f4 in clang::ODRDiagsEmitter::diagnoseMismatch(clang::FunctionDecl const*, clang::FunctionDecl const*) const () #242 0x0000000002b5b877 in clang::ASTReader::diagnoseOdrViolations() [clone .localalias] () #243 0x0000000002b5e761 in clang::ASTReader::FinishedDeserializing() [clone .part.0] () #244 0x0000000002bbac65 in clang::ASTReader::ReadDeclRecord(unsigned int) () #245 0x0000000002b4d6c9 in clang::ASTReader::GetDecl(unsigned int) [clone .localalias] () #246 0x0000000002b665c3 in clang::ASTReader::completeVisibleDeclsMap(clang::DeclContext const*) [clone .part.0] () #247 0x00000000018c2e1e in (anonymous namespace)::LookupVisibleHelper::lookupInDeclContext(clang::DeclContext*, clang::LookupResult&, bool, bool) () #248 0x00000000018c5282 in clang::Sema::LookupVisibleDecls(clang::DeclContext*, clang::Sema::LookupNameKind, clang::VisibleDeclConsumer&, bool, bool, bool) [clone .localalias] () #249 0x00000000018cf4f4 in clang::Sema::makeTypoCorrectionConsumer(clang::DeclarationNameInfo const&, clang::Sema::LookupNameKind, clang::Scope*, clang::CXXScopeSpec*, clang::CorrectionCandidateCallback&, clang::DeclContext*, bool, clang::ObjCObjectPointerType const*, bool) [clone .localalias] () #250 0x00000000018d0c1d in clang::Sema::CorrectTypo(clang::DeclarationNameInfo const&, clang::Sema::LookupNameKind, clang::Scope*, clang::CXXScopeSpec*, clang::CorrectionCandidateCallback&, clang::Sema::CorrectTypoKind, clang::DeclContext*, bool, clang::ObjCObjectPointerType const*, bool) () #251 0x0000000001536b02 in clang::Sema::DiagnoseUnknownTypeName(clang::IdentifierInfo*&, clang::SourceLocation, clang::Scope*, clang::CXXScopeSpec*, clang::OpaquePtr<clang::QualType>&, bool) () #252 0x0000000002a1a27d in clang::Parser::ParseImplicitInt(clang::DeclSpec&, clang::CXXScopeSpec*, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) [clone .localalias] () #253 0x0000000002a1e49c in clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) [clone .localalias] () #254 0x0000000002af8dad in clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) [clone .localalias] () #255 0x0000000002af9e9f in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) [clone .part.0] () #256 0x0000000002b00676 in clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) [clone .localalias] () #257 0x0000000002b018da in clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) [clone .localalias] () #258 0x00000000029fe3ca in clang::ParseAST(clang::Sema&, bool, bool) [clone .localalias] () #259 0x000000000116f5f9 in clang::FrontendAction::Execute() () #260 0x0000000001ee75fd in clang::clangd::ParsedAST::build (Filename=..., Inputs=..., CI=..., CompilerInvocationDiags=..., Preamble=...) at /llvmorg-17.0.3/clang-tools-extra/clangd/ParsedAST.cpp:669 #261 0x0000000001f5d462 in clang::clangd::(anonymous namespace)::ASTWorker::generateDiagnostics (this=0x3946950, Invocation=..., Inputs=..., CIDiags=...) at /opt/gcc-11.1.0/include/c++/11.1.0/bits/basic_string.h:912 #262 0x0000000001f5dd83 in operator() (__closure=0x7f4cf80022d0) at /opt/gcc-11.1.0/include/c++/11.1.0/bits/unique_ptr.h:172 #263 0x0000000001f56965 in llvm::unique_function<void ()>::operator()() (this=0x3946bb0) at /llvmorg-17.0.3/llvm/include/llvm/ADT/FunctionExtras.h:382 #264 llvm::function_ref<void ()>::callback_fn<llvm::unique_function<void ()> >(long) (callable=60058544) at /llvmorg-17.0.3/llvm/include/llvm/ADT/STLFunctionalExtras.h:45 #265 llvm::function_ref<void ()>::operator()() const (this=<synthetic pointer>) at /llvmorg-17.0.3/llvm/include/llvm/ADT/STLFunctionalExtras.h:68 #266 clang::clangd::(anonymous namespace)::ASTWorker::runTask(llvm::StringRef, llvm::function_ref<void()>) (this=this@entry=0x3946950, Name=..., Task=...) at /llvmorg-17.0.3/clang-tools-extra/clangd/TUScheduler.cpp:1324 #267 0x0000000001f58439 in clang::clangd::(anonymous namespace)::ASTWorker::run (this=0x3946950) at /llvmorg-17.0.3/clang-tools-extra/clangd/TUScheduler.cpp:1458 #268 0x0000000002106f25 in llvm::unique_function<void ()>::operator()() (this=0x392abc0) at /llvmorg-17.0.3/llvm/include/llvm/ADT/FunctionExtras.h:382 #269 operator() (__closure=0x392aba0) at /llvmorg-17.0.3/clang-tools-extra/clangd/support/Threading.cpp:101 #270 operator()<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()>&> (F=..., __closure=<optimized out>) at /llvmorg-17.0.3/llvm/include/llvm/Support/thread.h:43 #271 std::__invoke_impl<void, llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()>&> (__f=...) at /opt/gcc-11.1.0/include/c++/11.1.0/bits/invoke.h:61 #272 std::__invoke<llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()>&> (__fn=...) at /opt/gcc-11.1.0/include/c++/11.1.0/bits/invoke.h:96 #273 std::__apply_impl<llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> >&, 0> (__t=..., __f=...) at /opt/gcc-11.1.0/include/c++/11.1.0/tuple:1806 #274 std::apply<llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> >&> (__t=..., __f=...) at /opt/gcc-11.1.0/include/c++/11.1.0/tuple:1817 #275 llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > > (Ptr=0x392aba0) at /llvmorg-17.0.3/llvm/include/llvm/Support/thread.h:41 #276 llvm::thread::ThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void *) (Ptr=0x392aba0) at /llvmorg-17.0.3/llvm/include/llvm/Support/thread.h:55 #277 0x00007f4d2e258e25 in start_thread () from /lib64/libpthread.so.0 #278 0x00007f4d2d22335d in clone () from /lib64/libc.so.6 ``` the input to `clang::Diagnostic::FormatDiagnostic` look like this: ``` f 232 #232 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67eeea <(anonymous namespace)::StaticDiagInfoDescriptions+97610> " first difference is %select{return type is %4|%ordinal4 parameter with name %5|%ordinal4 parameter with type %5%select{| decayed from %7}6|%ordinal4 parameter with%select{out|}5 a default argument|%o"..., DiagEnd=<optimized out>, OutStr=...) at /source/install/llvm/llvm.git/clang/lib/Basic/Diagnostic.cpp:1001 1001 HandleSelectModifier(*this, Val, Argument, ArgumentLen, OutStr); (gdb) p DiagStr $5 = 0x67eeea <(anonymous namespace)::StaticDiagInfoDescriptions+97610> " first difference is %select{return type is %4|%ordinal4 parameter with name %5|%ordinal4 parameter with type %5%select{| decayed from %7}6|%ordinal4 parameter with%select{out|}5 a default argument|%o"... (gdb) printf "%s\n", DiagStr first difference is %select{return type is %4|%ordinal4 parameter with name %5|%ordinal4 parameter with type %5%select{| decayed from %7}6|%ordinal4 parameter with%select{out|}5 a default argument|%ordinal4 parameter with a default argument|function body}3 (gdb) ``` and the `OutStr` contains the hugh memory ``` (gdb) p OutStr $24 = (llvm::SmallVectorImpl<char> &) @0x7f4d25ff6500: { <llvm::SmallVectorTemplateBase<char, true>> = { <llvm::SmallVectorTemplateCommon<char, void>> = { <llvm::SmallVectorBase<unsigned long>> = { BeginX = 0x7f48d43fa010, Size = 4511505832, Capacity = 8724152319 }, <No data fields>}, members of llvm::SmallVectorTemplateBase<char, true>: static TakesParamByValue = true }, <No data fields>} (gdb) ``` the content of `OutStr` ``` (gdb) x /20xs (0x7f48d43fa010) 0x7f48d43fa010: "'std::midpoint' has different definitions in different modules; 1 first difference is '_Tp'" 0x7f48d43fa06c: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa0bf: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa112: " 1 has different definitions in different modules; first difference is this '_Tp'" 0x7f48d43fa164: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa1b7: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa20a: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa25d: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa2b0: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa303: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa356: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa3a9: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa3fc: "template parameter lists have a different number of parameters ( vs 2)" 0x7f48d43fa443: "template parameter has different kinds in different translation units" 0x7f48d43fa489: "field declared with incompatible types in different translation units (2 vs. 1)" 0x7f48d43fa4da: "external function declared with incompatible types in different translation units (2 vs. 1)" 0x7f48d43fa537: "instance variable declared with incompatible types in different translation units (2 vs. 1)" 0x7f48d43fa594: "non-type template parameter declared with incompatible types in different translation units ( vs. 2)" 0x7f48d43fa5f9: " method 2 has a different number of parameters in different translation units (1 vs. '_Tp')" 0x7f48d43fa655: " method 2 has a parameter with a different types in different translation units (1 vs. '_Tp')" (gdb) x /20xs (0x7f48d43fa010 + 4511505832 - 200) 0x7f49e127bcf0: "ncurrent" 0x7f49e127bcf9: "expected in OpenMP clause '2'" 0x7f49e127bd18: "modifier '' cannot be used along with modifier '2'" 0x7f49e127bd4b: "mapping of union members is not allowed" 0x7f49e127bd73: "incorrect reduction identifier, expected one of '+', '-', '*', '&', '" 0x7f49e127bdb9: "" 0x7f49e127bdba: "" 0x7f49e127bdbb: "" 0x7f49e127bdbc: "" 0x7f49e127bdbd: "" 0x7f49e127bdbe: "" ```
llvmbot commented 9 months ago

@llvm/issue-subscribers-clang-modules

Author: ZHU ZHIPU (coreyzzp)

version : llvmorg-17.0.3 Recently, when using clangd in vscode remote, once a certain file is encountered, the memory will explode, eventually causing the entire machine to go out of memory (clangd consumes more than 64G of memory). Below is the stack (using the release version, compiled with -g) ``` #0 0x00007f4d2d1a8233 in _int_malloc () from /lib64/libc.so.6 #1 0x00007f4d2d1ab10c in malloc () from /lib64/libc.so.6 #2 0x0000000000a2b2d8 in llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long) () #3 0x0000000000f35070 in llvm::SmallVectorTemplateCommon<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, void>::grow_pod (TSize=16, MinSize=<optimized out>, this=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:140 #4 llvm::SmallVectorTemplateBase<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, true>::grow (MinSize=<optimized out>, this=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:529 #5 llvm::SmallVectorTemplateCommon<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, void>::reserveForParamAndGetAddressImpl<llvm::SmallVectorTemplateBase<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, true> > (N=1, Elt=<synthetic pointer>..., This=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:246 #6 llvm::SmallVectorTemplateBase<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, true>::reserveForParamAndGetAddress (N=1, Elt=<synthetic pointer>..., this=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:541 #7 llvm::SmallVectorTemplateBase<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, true>::push_back (Elt=..., this=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:566 #8 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a4068 <(anonymous namespace)::StaticDiagInfoDescriptions+249544> "'", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1142 #9 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #10 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a3d23 <(anonymous namespace)::StaticDiagInfoDescriptions+248707> ")' clause%select{s|}1", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #11 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #12 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a3cf0 <(anonymous namespace)::StaticDiagInfoDescriptions+248656> " cannot be mixed with '%0(%select{sink:vec|source}1)' clause%select{s|}1", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #13 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #14 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a3cdb <(anonymous namespace)::StaticDiagInfoDescriptions+248635> ")' clause%select{|s}1 cannot be mixed with '%0(%select{sink:vec|source}1)' clause%select{s|}1", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #15 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #16 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a2e66 <(anonymous namespace)::StaticDiagInfoDescriptions+244934> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #17 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #18 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a138a <(anonymous namespace)::StaticDiagInfoDescriptions+238058> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #19 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #20 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a08f0 <(anonymous namespace)::StaticDiagInfoDescriptions+235344> " type", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #21 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #22 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69fb28 <(anonymous namespace)::StaticDiagInfoDescriptions+231816> ", not %0", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #23 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #24 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69f1b4 <(anonymous namespace)::StaticDiagInfoDescriptions+229396> " because assigning method's 2nd parameter of type %0 is not an Objective-C pointer type", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #25 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #26 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69ea67 <(anonymous namespace)::StaticDiagInfoDescriptions+227527> " element must have Objective-C object return type instead of %0", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #27 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #28 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69e6bf <(anonymous namespace)::StaticDiagInfoDescriptions+226591> " %3", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #29 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #30 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69e660 <(anonymous namespace)::StaticDiagInfoDescriptions+226496> " declaration conflicts with previous %select{|direct }2declaration of %select{method|property}1 %3", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #31 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #32 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69e3eb <(anonymous namespace)::StaticDiagInfoDescriptions+225867> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #33 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #34 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69c9ab <(anonymous namespace)::StaticDiagInfoDescriptions+219147> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #35 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #36 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69bde6 <(anonymous namespace)::StaticDiagInfoDescriptions+216134> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #37 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #38 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69b4bd <(anonymous namespace)::StaticDiagInfoDescriptions+213789> " follows declaration in %select{the global module|module %4}3", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #39 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #40 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69b239 <(anonymous namespace)::StaticDiagInfoDescriptions+213145> " method %0 not found ; did you mean %2?", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #41 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #42 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69ad1b <(anonymous namespace)::StaticDiagInfoDescriptions+211835> ", but function has %select{non-const lvalue|rvalue}2 ref-qualifier", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #43 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #44 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69aa5c <(anonymous namespace)::StaticDiagInfoDescriptions+211132> " %2?", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #45 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #46 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69a6ec <(anonymous namespace)::StaticDiagInfoDescriptions+210252> " integers and enum types, but was given %2%select{| whose underlying type is %4}3", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 ....... ....... ....... something like FormatDiagnostic ....... ....... ....... ....... #224 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67f46c <(anonymous namespace)::StaticDiagInfoDescriptions+99020> " found %select{%select{no super class|super class with type %5}4|instance variable '%4' access control is %select{|@private|@protected|@public|@package}5}3", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #225 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #226 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67f30c <(anonymous namespace)::StaticDiagInfoDescriptions+98668> " has different definitions in different modules; first difference is this %select{||||static assert|field|method|type alias|typedef|data member|friend declaration|function template|method|instance var"..., DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #227 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #228 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67f1e8 <(anonymous namespace)::StaticDiagInfoDescriptions+98376> " found %select{end of class|public access specifier|private access specifier|protected access specifier|static assert|field|method|type alias|typedef|data member|friend declaration|function template|m"..., DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #229 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #230 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67f064 <(anonymous namespace)::StaticDiagInfoDescriptions+97988> " found %select{%select{method %5|constructor|destructor}4 that has %6 parameter%s6|%select{method %5|constructor|destructor}4 with %ordinal6 parameter of type %7%select{| decayed from %9}8|%select{met"..., DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #231 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #232 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67eeea <(anonymous namespace)::StaticDiagInfoDescriptions+97610> " first difference is %select{return type is %4|%ordinal4 parameter with name %5|%ordinal4 parameter with type %5%select{| decayed from %7}6|%ordinal4 parameter with%select{out|}5 a default argument|%o"..., DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #233 0x0000000001de8f76 in clang::clangd::fillNonLocationData (DiagLevel=clang::DiagnosticsEngine::Error, Info=..., D=...) at /llvmorg-17.0.3/clang-tools-extra/clangd/Diagnostics.cpp:664 #234 0x0000000001dea974 in operator() (__closure=__closure@entry=0x7f4d25ff66e0, D=...) at /llvmorg-17.0.3/clang-tools-extra/clangd/Diagnostics.cpp:720 #235 0x0000000001df8222 in clang::clangd::StoreDiags::HandleDiagnostic (this=0x7f4d25ff9be0, DiagLevel=<optimized out>, Info=...) at /opt/gcc-11.1.0/include/c++/11.1.0/optional:440 #236 0x0000000000f3a572 in clang::DiagnosticIDs::EmitDiag (DiagLevel=clang::DiagnosticIDs::Error, Diag=..., this=0x7f4d1c01e1f0) at /llvmorg-17.0.3/clang/lib/Basic/DiagnosticIDs.cpp:823 #237 clang::DiagnosticIDs::ProcessDiag (this=this@entry=0x7f4d1c01e1f0, Diag=...) at /llvmorg-17.0.3/clang/lib/Basic/DiagnosticIDs.cpp:815 #238 0x0000000000f33f1b in clang::DiagnosticsEngine::ProcessDiag (this=0x7f4d1c001990) at /llvmorg-17.0.3/clang/include/clang/Basic/Diagnostic.h:1037 #239 clang::DiagnosticsEngine::EmitCurrentDiagnostic (this=0x7f4d1c001990, Force=<optimized out>) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:545 #240 0x0000000000b61590 in clang::DiagnosticBuilder::~DiagnosticBuilder() () #241 0x0000000000e0f1f4 in clang::ODRDiagsEmitter::diagnoseMismatch(clang::FunctionDecl const*, clang::FunctionDecl const*) const () #242 0x0000000002b5b877 in clang::ASTReader::diagnoseOdrViolations() [clone .localalias] () #243 0x0000000002b5e761 in clang::ASTReader::FinishedDeserializing() [clone .part.0] () #244 0x0000000002bbac65 in clang::ASTReader::ReadDeclRecord(unsigned int) () #245 0x0000000002b4d6c9 in clang::ASTReader::GetDecl(unsigned int) [clone .localalias] () #246 0x0000000002b665c3 in clang::ASTReader::completeVisibleDeclsMap(clang::DeclContext const*) [clone .part.0] () #247 0x00000000018c2e1e in (anonymous namespace)::LookupVisibleHelper::lookupInDeclContext(clang::DeclContext*, clang::LookupResult&, bool, bool) () #248 0x00000000018c5282 in clang::Sema::LookupVisibleDecls(clang::DeclContext*, clang::Sema::LookupNameKind, clang::VisibleDeclConsumer&, bool, bool, bool) [clone .localalias] () #249 0x00000000018cf4f4 in clang::Sema::makeTypoCorrectionConsumer(clang::DeclarationNameInfo const&, clang::Sema::LookupNameKind, clang::Scope*, clang::CXXScopeSpec*, clang::CorrectionCandidateCallback&, clang::DeclContext*, bool, clang::ObjCObjectPointerType const*, bool) [clone .localalias] () #250 0x00000000018d0c1d in clang::Sema::CorrectTypo(clang::DeclarationNameInfo const&, clang::Sema::LookupNameKind, clang::Scope*, clang::CXXScopeSpec*, clang::CorrectionCandidateCallback&, clang::Sema::CorrectTypoKind, clang::DeclContext*, bool, clang::ObjCObjectPointerType const*, bool) () #251 0x0000000001536b02 in clang::Sema::DiagnoseUnknownTypeName(clang::IdentifierInfo*&, clang::SourceLocation, clang::Scope*, clang::CXXScopeSpec*, clang::OpaquePtr<clang::QualType>&, bool) () #252 0x0000000002a1a27d in clang::Parser::ParseImplicitInt(clang::DeclSpec&, clang::CXXScopeSpec*, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) [clone .localalias] () #253 0x0000000002a1e49c in clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) [clone .localalias] () #254 0x0000000002af8dad in clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) [clone .localalias] () #255 0x0000000002af9e9f in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) [clone .part.0] () #256 0x0000000002b00676 in clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) [clone .localalias] () #257 0x0000000002b018da in clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) [clone .localalias] () #258 0x00000000029fe3ca in clang::ParseAST(clang::Sema&, bool, bool) [clone .localalias] () #259 0x000000000116f5f9 in clang::FrontendAction::Execute() () #260 0x0000000001ee75fd in clang::clangd::ParsedAST::build (Filename=..., Inputs=..., CI=..., CompilerInvocationDiags=..., Preamble=...) at /llvmorg-17.0.3/clang-tools-extra/clangd/ParsedAST.cpp:669 #261 0x0000000001f5d462 in clang::clangd::(anonymous namespace)::ASTWorker::generateDiagnostics (this=0x3946950, Invocation=..., Inputs=..., CIDiags=...) at /opt/gcc-11.1.0/include/c++/11.1.0/bits/basic_string.h:912 #262 0x0000000001f5dd83 in operator() (__closure=0x7f4cf80022d0) at /opt/gcc-11.1.0/include/c++/11.1.0/bits/unique_ptr.h:172 #263 0x0000000001f56965 in llvm::unique_function<void ()>::operator()() (this=0x3946bb0) at /llvmorg-17.0.3/llvm/include/llvm/ADT/FunctionExtras.h:382 #264 llvm::function_ref<void ()>::callback_fn<llvm::unique_function<void ()> >(long) (callable=60058544) at /llvmorg-17.0.3/llvm/include/llvm/ADT/STLFunctionalExtras.h:45 #265 llvm::function_ref<void ()>::operator()() const (this=<synthetic pointer>) at /llvmorg-17.0.3/llvm/include/llvm/ADT/STLFunctionalExtras.h:68 #266 clang::clangd::(anonymous namespace)::ASTWorker::runTask(llvm::StringRef, llvm::function_ref<void()>) (this=this@entry=0x3946950, Name=..., Task=...) at /llvmorg-17.0.3/clang-tools-extra/clangd/TUScheduler.cpp:1324 #267 0x0000000001f58439 in clang::clangd::(anonymous namespace)::ASTWorker::run (this=0x3946950) at /llvmorg-17.0.3/clang-tools-extra/clangd/TUScheduler.cpp:1458 #268 0x0000000002106f25 in llvm::unique_function<void ()>::operator()() (this=0x392abc0) at /llvmorg-17.0.3/llvm/include/llvm/ADT/FunctionExtras.h:382 #269 operator() (__closure=0x392aba0) at /llvmorg-17.0.3/clang-tools-extra/clangd/support/Threading.cpp:101 #270 operator()<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()>&> (F=..., __closure=<optimized out>) at /llvmorg-17.0.3/llvm/include/llvm/Support/thread.h:43 #271 std::__invoke_impl<void, llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()>&> (__f=...) at /opt/gcc-11.1.0/include/c++/11.1.0/bits/invoke.h:61 #272 std::__invoke<llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()>&> (__fn=...) at /opt/gcc-11.1.0/include/c++/11.1.0/bits/invoke.h:96 #273 std::__apply_impl<llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> >&, 0> (__t=..., __f=...) at /opt/gcc-11.1.0/include/c++/11.1.0/tuple:1806 #274 std::apply<llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> >&> (__t=..., __f=...) at /opt/gcc-11.1.0/include/c++/11.1.0/tuple:1817 #275 llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > > (Ptr=0x392aba0) at /llvmorg-17.0.3/llvm/include/llvm/Support/thread.h:41 #276 llvm::thread::ThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void *) (Ptr=0x392aba0) at /llvmorg-17.0.3/llvm/include/llvm/Support/thread.h:55 #277 0x00007f4d2e258e25 in start_thread () from /lib64/libpthread.so.0 #278 0x00007f4d2d22335d in clone () from /lib64/libc.so.6 ``` the input to `clang::Diagnostic::FormatDiagnostic` look like this: ``` f 232 #232 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67eeea <(anonymous namespace)::StaticDiagInfoDescriptions+97610> " first difference is %select{return type is %4|%ordinal4 parameter with name %5|%ordinal4 parameter with type %5%select{| decayed from %7}6|%ordinal4 parameter with%select{out|}5 a default argument|%o"..., DiagEnd=<optimized out>, OutStr=...) at /source/install/llvm/llvm.git/clang/lib/Basic/Diagnostic.cpp:1001 1001 HandleSelectModifier(*this, Val, Argument, ArgumentLen, OutStr); (gdb) p DiagStr $5 = 0x67eeea <(anonymous namespace)::StaticDiagInfoDescriptions+97610> " first difference is %select{return type is %4|%ordinal4 parameter with name %5|%ordinal4 parameter with type %5%select{| decayed from %7}6|%ordinal4 parameter with%select{out|}5 a default argument|%o"... (gdb) printf "%s\n", DiagStr first difference is %select{return type is %4|%ordinal4 parameter with name %5|%ordinal4 parameter with type %5%select{| decayed from %7}6|%ordinal4 parameter with%select{out|}5 a default argument|%ordinal4 parameter with a default argument|function body}3 (gdb) ``` and the `OutStr` contains the hugh memory ``` (gdb) p OutStr $24 = (llvm::SmallVectorImpl<char> &) @0x7f4d25ff6500: { <llvm::SmallVectorTemplateBase<char, true>> = { <llvm::SmallVectorTemplateCommon<char, void>> = { <llvm::SmallVectorBase<unsigned long>> = { BeginX = 0x7f48d43fa010, Size = 4511505832, Capacity = 8724152319 }, <No data fields>}, members of llvm::SmallVectorTemplateBase<char, true>: static TakesParamByValue = true }, <No data fields>} (gdb) ``` the content of `OutStr` ``` (gdb) x /20xs (0x7f48d43fa010) 0x7f48d43fa010: "'std::midpoint' has different definitions in different modules; 1 first difference is '_Tp'" 0x7f48d43fa06c: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa0bf: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa112: " 1 has different definitions in different modules; first difference is this '_Tp'" 0x7f48d43fa164: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa1b7: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa20a: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa25d: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa2b0: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa303: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa356: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa3a9: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa3fc: "template parameter lists have a different number of parameters ( vs 2)" 0x7f48d43fa443: "template parameter has different kinds in different translation units" 0x7f48d43fa489: "field declared with incompatible types in different translation units (2 vs. 1)" 0x7f48d43fa4da: "external function declared with incompatible types in different translation units (2 vs. 1)" 0x7f48d43fa537: "instance variable declared with incompatible types in different translation units (2 vs. 1)" 0x7f48d43fa594: "non-type template parameter declared with incompatible types in different translation units ( vs. 2)" 0x7f48d43fa5f9: " method 2 has a different number of parameters in different translation units (1 vs. '_Tp')" 0x7f48d43fa655: " method 2 has a parameter with a different types in different translation units (1 vs. '_Tp')" (gdb) x /20xs (0x7f48d43fa010 + 4511505832 - 200) 0x7f49e127bcf0: "ncurrent" 0x7f49e127bcf9: "expected in OpenMP clause '2'" 0x7f49e127bd18: "modifier '' cannot be used along with modifier '2'" 0x7f49e127bd4b: "mapping of union members is not allowed" 0x7f49e127bd73: "incorrect reduction identifier, expected one of '+', '-', '*', '&', '" 0x7f49e127bdb9: "" 0x7f49e127bdba: "" 0x7f49e127bdbb: "" 0x7f49e127bdbc: "" 0x7f49e127bdbd: "" 0x7f49e127bdbe: "" ```
kadircet commented 9 months ago

hi @coreyzzp ! It looks like you're using clangd on a modules enabled build, unfortunately that's not something we support (explicitly) today.

Can you share the logs from clangd with -log=verbose passed to clangd as command line flag, so that we can see compile flags being used? That way we can check it's indeed an issue related to modules being enabled for your compilation. Unfortunately the workaround would be to disable modules for now (that is, if your compilation can be carried on without modules).

coreyzzp commented 9 months ago

hi @coreyzzp ! It looks like you're using clangd on a modules enabled build, unfortunately that's not something we support (explicitly) today.

Can you share the logs from clangd with -log=verbose passed to clangd as command line flag, so that we can see compile flags being used? That way we can check it's indeed an issue related to modules being enabled for your compilation. Unfortunately the workaround would be to disable modules for now (that is, if your compilation can be carried on without modules).

sorry I can not reproduce the program now because I add following code to get ride of the problem

void Diagnostic::
FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
                 SmallVectorImpl<char> &OutStr) const {

  if (OutStr.size() > 100*1024*1024) { // fix possible bug
    return;
  }

but i can share with previous file causing the BUG, I do not use any module feature

/source/install/llvm/llvm-17.0.3/bin/clang
-D_USE_TCMALLOC_
-D_NO_MSG_STAT
-D_HL_GAMESVR_
-Dlinux
-D__STDC_FORMAT_MACROS
-D_GAME_SO_
-D_FILE_OFFSET_BITS=64
-D_NO_SO_
-D_GLIBCXX_USE_CXX11_ABI=0
-D_BAZEL_BUILD_
-DGTEST_DONT_DEFINE_FAIL=1
-D_DK_ATTR_HOOK_
-D_DEBUG_
-D_DEBUG_DDZ3D_
-D_BUILD_SCRIPT_ddzbuild_
-D_IN_DEV_EDITOR_
-DSVN_REVISION=0
-DSVN_REVISION=0
-D_GAME_SO_
-D_JIE_LONG_TEST_
-D_LINUX_
-DHASHMAP_USE_LIST
-D_DOWNCAST_
-D_PYTHON_WRAPPER_
-D_HLDDZ_
-D_NEW_PLUGIN_
-D_NOT_USE_DDZSO_PLUGIN_
-Wno-undefined-bool-conversion
-std=c++20
-fexperimental-library
-I<BUSSINESS_INCLUDE>
-isystem/opt/llvm-17.0.3/include/x86_64-unknown-linux-gnu/c++/v1
-isystem/opt/llvm-17.0.3/include/c++/v1
-resource-dir=/source/install/llvm/llvm.git.run.debugsymbol/lib/clang/17
--
<BUSSINESS_FILE>.cpp
vvd170501 commented 1 month ago

Hi. I have the same or very similar issue with clangd 18 (llvmorg-18.1.8),

Stack trace ``` #0 __GI___libc_malloc (bytes=272) at ./malloc/malloc.c:3287 #1 0x0000561e26c5f7d3 in llvm::safe_malloc (Sz=272) at /opt/llvm-project/llvm/include/llvm/Support/MemAlloc.h:26 #2 llvm::SmallVectorBase::grow_pod (this=0x7f1354fe0968, FirstEl=0x7f1354fe0978, MinSize=9, TSize=16) at /opt/llvm-project/llvm/lib/Support/SmallVector.cpp:143 #3 0x0000561e270c423a in llvm::SmallVectorTemplateCommon, void>::grow_pod (this=0x7f1354fe0968, MinSize=9, TSize=16) at /opt/llvm-project/llvm/include/llvm/ADT/SmallVector.h:151 #4 llvm::SmallVectorTemplateBase, true>::grow (this=0x7f1354fe0968, MinSize=9) at /opt/llvm-project/llvm/include/llvm/ADT/SmallVector.h:538 #5 llvm::SmallVectorTemplateCommon, void>::reserveForParamAndGetAddressImpl, true> > (This=0x7f1354fe0968, N=1, Elt=...) at /opt/llvm-project/llvm/include/llvm/ADT/SmallVector.h:256 #6 llvm::SmallVectorTemplateBase, true>::reserveForParamAndGetAddress (this=0x7f1354fe0968, N=1, Elt=...) at /opt/llvm-project/llvm/include/llvm/ADT/SmallVector.h:550 #7 llvm::SmallVectorTemplateBase, true>::push_back (this=0x7f1354fe0968, Elt={...}) at /opt/llvm-project/llvm/include/llvm/ADT/SmallVector.h:575 #8 clang::Diagnostic::FormatDiagnostic (this=0x7f1354ff09e8, DiagStr=0x561e28c26b12 <(anonymous namespace)::StaticDiagInfoDescriptions+257370> "'", DiagEnd=0x561e28c26b81 <(anonymous namespace)::StaticDiagInfoDescriptions+257481> "|', '^', '&&', '||', 'min' or 'max' or declare reduction for type %0", OutStr=...) at /opt/llvm-project/clang/lib/Basic/Diagnostic.cpp:1143 #9 0x0000561e270c4218 in HandleSelectModifier (DInfo=..., ValNo=, Argument=, ArgumentLen=, OutStr=...) at /opt/llvm-project/clang/lib/Basic/Diagnostic.cpp:628 #10 0x0000561e270c4218 in clang::Diagnostic::FormatDiagnostic (this=0x7f1354ff09e8, DiagStr=0x561e28c26775 <(anonymous namespace)::StaticDiagInfoDescriptions+256445> ")' clause%select{s|}1", DiagEnd=0x561e28c26b81 <(anonymous namespace)::StaticDiagInfoDescriptions+257481> "|', '^', '&&', '||', 'min' or 'max' or declare reduction for type %0", OutStr=...) #11 0x0000561e270c4218 in HandleSelectModifier (DInfo=..., ValNo=, Argument=, ArgumentLen=, OutStr=...) at /opt/llvm-project/clang/lib/Basic/Diagnostic.cpp:628 #12 0x0000561e270c4218 in clang::Diagnostic::FormatDiagnostic (this=0x7f1354ff09e8, DiagStr=0x561e28c26589 <(anonymous namespace)::StaticDiagInfoDescriptions+255953> "'acq_rel', 'acquire' or 'release' clause", DiagEnd=0x561e28c26b81 <(anonymous namespace)::StaticDiagInfoDescriptions+257481> "|', '^', '&&', '||', 'min' or 'max' or declare reduction for type %0", OutStr=...) #13 0x0000561e270c4218 in HandleSelectModifier (DInfo=..., ValNo=, Argument=, ArgumentLen=, OutStr=...) at /opt/llvm-project/clang/lib/Basic/Diagnostic.cpp:628 #14 0x0000561e270c4218 in clang::Diagnostic::FormatDiagnostic (this=0x7f1354ff09e8, DiagStr=0x561e28c2509e <(anonymous namespace)::StaticDiagInfoDescriptions+250598> " integer value", DiagEnd=0x561e28c26b81 <(anonymous namespace)::StaticDiagInfoDescriptions+257481> "|', '^', '&&', '||', 'min' or 'max' or declare reduction for type %0", OutStr=...) #15 0x0000561e270c4218 in HandleSelectModifier (DInfo=..., ValNo=, Argument=, ArgumentLen=, OutStr=...) at /opt/llvm-project/clang/lib/Basic/Diagnostic.cpp:628 #16 0x0000561e270c4218 in clang::Diagnostic::FormatDiagnostic (this=0x7f1354ff09e8, DiagStr=0x561e28c23d99 <(anonymous namespace)::StaticDiagInfoDescriptions+245729> "", DiagEnd=0x561e28c26b81 <(anonymous namespace)::StaticDiagInfoDescriptions+257481> "|', '^', '&&', '||', 'min' or 'max' or declare reduction for type %0", OutStr=...) #17 0x0000561e270c4218 in HandleSelectModifier (DInfo=..., ValNo=, Argument=, ArgumentLen=, OutStr=...) at /opt/llvm-project/clang/lib/Basic/Diagnostic.cpp:628 #18 0x0000561e270c4218 in clang::Diagnostic::FormatDiagnostic (this=0x7f1354ff09e8, DiagStr=0x561e28c232ff <(anonymous namespace)::StaticDiagInfoDescriptions+243015> " type", DiagEnd=0x561e28c26b81 <(anonymous namespace)::StaticDiagInfoDescriptions+257481> "|', '^', '&&', '||', 'min' or 'max' or declare reduction for type %0", OutStr=...) #19 0x0000561e270c4218 in HandleSelectModifier (DInfo=..., ValNo=, Argument=, ArgumentLen=, OutStr=...) at /opt/llvm-project/clang/lib/Basic/Diagnostic.cpp:628 #20 0x0000561e270c4218 in clang::Diagnostic::FormatDiagnostic (this=0x7f1354ff09e8, #21 0x0000561e270c4218 in HandleSelectModifier (DInfo=..., ValNo=, Argument=, ArgumentLen=, OutStr=...) at /opt/llvm-project/clang/lib/Basic/Diagnostic.cpp:628 #22 0x0000561e270c4218 in clang::Diagnostic::FormatDiagnostic (this=0x7f1354ff09e8, DiagStr=0x561e28c21aac <(anonymous namespace)::StaticDiagInfoDescriptions+236788> " %select{dictionary|array}2 element not found on object of type %0", DiagEnd=0x561e28c26b81 <(anonymous namespace)::StaticDiagInfoDescriptions+257481> "|', '^', '&&', '||', 'min' or 'max' or declare reduction for type %0", OutStr=...) #23 0x0000561e270c4218 in HandleSelectModifier (DInfo=..., ValNo=, Argument=, ArgumentLen=, OutStr=...) at /opt/llvm-project/clang/lib/Basic/Diagnostic.cpp:628 #24 0x0000561e270c4218 in clang::Diagnostic::FormatDiagnostic (this=0x7f1354ff09e8, DiagStr=0x561e28c219b9 <(anonymous namespace)::StaticDiagInfoDescriptions+236545> " subscript base type %0 is not an Objective-C object", DiagEnd=0x561e28c26b81 <(anonymous namespace)::StaticDiagInfoDescriptions+257481> "|', '^', '&&', '||', 'min' or 'max' or declare reduction for type %0", OutStr=...) #25 0x0000561e270c4218 in HandleSelectModifier (DInfo=..., ValNo=, Argument=, ArgumentLen=, OutStr=...) at /opt/llvm-project/clang/lib/Basic/Diagnostic.cpp:628 // Repeating HandleSelectModifier and FormatDiagnostic... #242 0x0000561e270c4218 in clang::Diagnostic::FormatDiagnostic (this=0x7f1354ff09e8, DiagStr=0x561e28c00b22 <(anonymous namespace)::StaticDiagInfoDescriptions+101738> " found %select{%select{method %5|constructor|destructor}4 that has %6 parameter%s6|%select{method %5|constructor|destructor}4 with %ordinal6 parameter of type %7%select{| decayed from %9}8|%select{met"..., DiagEnd=0x561e28c26b81 <(anonymous namespace)::StaticDiagInfoDescriptions+257481> "|', '^', '&&', '||', 'min' or 'max' or declare reduction for type %0", OutStr=...) #243 0x0000561e270c4218 in HandleSelectModifier (DInfo=..., ValNo=, Argument=, ArgumentLen=, OutStr=...) at /opt/llvm-project/clang/lib/Basic/Diagnostic.cpp:628 #244 0x0000561e270c4218 in clang::Diagnostic::FormatDiagnostic (this=0x7f1354ff09e8, DiagStr=0x561e28c009a8 <(anonymous namespace)::StaticDiagInfoDescriptions+101360> " first difference is %select{return type is %4|%ordinal4 parameter with name %5|%ordinal4 parameter with type %5%select{| decayed from %7}6|%ordinal4 parameter with%select{out|}5 a default argument|%o"..., DiagEnd=0x561e28c00aa9 <(anonymous namespace)::StaticDiagInfoDescriptions+101617> "", OutStr=...) #245 0x0000561e27a88ee2 in clang::clangd::fillNonLocationData (DiagLevel=clang::DiagnosticsEngine::Error, Info=..., D=...) at /opt/llvm-project/clang-tools-extra/clangd/Diagnostics.cpp:664 #246 0x0000561e27a891e5 in clang::clangd::StoreDiags::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&)::$_0::operator()(clang::clangd::DiagBase&) const (this=this@entry=0x7f1354ff07f0, D=...) at /opt/llvm-project/clang-tools-extra/clangd/Diagnostics.cpp:720 #247 0x0000561e27a88aac in clang::clangd::StoreDiags::HandleDiagnostic (this=0x7f1354ff7dd8, DiagLevel=clang::DiagnosticsEngine::Error, Info=...) at /opt/llvm-project/clang-tools-extra/clangd/Diagnostics.cpp:814 #248 0x0000561e270c7c2b in clang::DiagnosticIDs::EmitDiag (this=0x7f132c013d10, Diag=..., DiagLevel=clang::DiagnosticIDs::Error) at /opt/llvm-project/clang/lib/Basic/DiagnosticIDs.cpp:823 #249 clang::DiagnosticIDs::ProcessDiag (this=0x7f132c013d10, Diag=...) at /opt/llvm-project/clang/lib/Basic/DiagnosticIDs.cpp:815 #250 0x0000561e270c2472 in clang::DiagnosticsEngine::ProcessDiag (this=0x7f132c012d10) at /opt/llvm-project/clang/include/clang/Basic/Diagnostic.h:1042 #251 clang::DiagnosticsEngine::EmitCurrentDiagnostic (this=0x7f132c012d10, Force=) at /opt/llvm-project/clang/lib/Basic/Diagnostic.cpp:545 #252 0x0000561e28a36af7 in clang::DiagnosticBuilder::Emit (this=) at /opt/llvm-project/clang/include/clang/Basic/Diagnostic.h:1325 #253 clang::DiagnosticBuilder::~DiagnosticBuilder (this=) at /opt/llvm-project/clang/include/clang/Basic/Diagnostic.h:1366 #254 0x0000561e28a36af7 in clang::ODRDiagsEmitter::diagnoseMismatch (this=, FirstFunction=0x7f132c59e440, SecondFunction=0x7f132c59deb0) #255 0x0000561e286ba1f0 in clang::ASTReader::diagnoseOdrViolations (this=this@entry=0x7f132c072d60) at /opt/llvm-project/clang/lib/Serialization/ASTReader.cpp:10010 #256 0x0000561e286badbe in clang::ASTReader::FinishedDeserializing (this=0x7f132c072d60) at /opt/llvm-project/clang/lib/Serialization/ASTReader.cpp:10132 #257 0x0000561e28701ec5 in clang::ExternalASTSource::Deserializing::~Deserializing (this=) at /opt/llvm-project/clang/include/clang/AST/ExternalASTSource.h:86 #258 clang::ASTReader::ReadDeclRecord (this=0x7f132c072d60, ID=) at /opt/llvm-project/clang/lib/Serialization/ASTReaderDecl.cpp:4163 #259 0x0000561e286a7343 in clang::ASTReader::GetDecl (this=this@entry=0x7f132c072d60, ID=6197) at /opt/llvm-project/clang/lib/Serialization/ASTReader.cpp:7781 #260 0x0000561e286b090c in clang::ASTReader::completeVisibleDeclsMap (this=0x7f132c072d60, DC=0x7f132c1228f8) at /opt/llvm-project/clang/lib/Serialization/ASTReader.cpp:7994 #261 0x0000561e271e91a2 in clang::DeclContext::lookups (this=0x7f132c2bf470) at /opt/llvm-project/clang/include/clang/AST/DeclLookups.h:78 #262 (anonymous namespace)::LookupVisibleHelper::lookupInDeclContext (this=this@entry=0x7f1354ff1688, Ctx=Ctx@entry=0x7f132c2bf470, Result=..., QualifiedNameLookup=true, InBaseClass=false) at /opt/llvm-project/clang/lib/Sema/SemaLookup.cpp:4176 #263 0x0000561e271db4b5 in (anonymous namespace)::LookupVisibleHelper::lookupVisibleDecls (this=0x7f1354ff1688, SemaRef=..., Kind=, Ctx=, IncludeGlobalScope=) at /opt/llvm-project/clang/lib/Sema/SemaLookup.cpp:4118 #264 clang::Sema::LookupVisibleDecls (this=this@entry=0x7f132c233260, Ctx=0x7f132c2bf470, Kind=, Consumer=..., IncludeGlobalScope=true, IncludeDependentBases=, LoadExternal=) at /opt/llvm-project/clang/lib/Sema/SemaLookup.cpp:4425 #265 0x0000561e271df375 in clang::Sema::makeTypoCorrectionConsumer (this=this@entry=0x7f132c233260, TypoName=..., LookupKind=clang::Sema::LookupOrdinaryName, S=0x7f132c009ba0, SS=0x7f1354ff39c0, CCC=..., MemberContext=0x0, EnteringContext=false, OPT=0x0, ErrorRecovery=) at /opt/llvm-project/clang/lib/Sema/SemaLookup.cpp:5271 #266 0x0000561e271e0dc4 in clang::Sema::CorrectTypoDelayed(clang::DeclarationNameInfo const&, clang::Sema::LookupNameKind, clang::Scope*, clang::CXXScopeSpec*, clang::CorrectionCandidateCallback&, std::function, std::function (clang::Sema&, clang::TypoExpr*, clang::TypoCorrection)>, clang::Sema::CorrectTypoKind, clang::DeclContext*, bool, clang::ObjCObjectPointerType const*) (this=0x7f132c233260, TypoName=..., LookupKind=clang::Sema::LookupOrdinaryName, S=0x7f132c009ba0, SS=0x7f1354ff39c0, CCC=..., TDG=..., TRC=..., Mode=, MemberContext=, EnteringContext=, OPT=) at /opt/llvm-project/clang/lib/Sema/SemaLookup.cpp:5498 #267 0x0000561e27633b8f in clang::Sema::DiagnoseEmptyLookup (this=, this@entry=0x7f132c233260, S=0x7f132c009ba0, S@entry=0x0, SS=..., R=..., CCC=..., ExplicitTemplateArgs=, ExplicitTemplateArgs@entry=0x0, Args=..., LookupCtx=, Out=) at /opt/llvm-project/clang/lib/Sema/SemaExpr.cpp:2527 #268 0x0000561e2762d349 in clang::Sema::ActOnIdExpression (this=0x7f132c233260, S=, SS=..., TemplateKWLoc=..., Id=..., HasTrailingLParen=, IsAddressOfOperand=, CCC=, IsInlineAsmIdentifier=, KeywordReplacement=) at /opt/llvm-project/clang/lib/Sema/SemaExpr.cpp:2827 #269 0x0000561e287f1ae7 in clang::Parser::tryParseCXXIdExpression (this=this@entry=0x7f132c238a70, SS=..., isAddressOfOperand=, Replacement=...) at /opt/llvm-project/clang/lib/Parse/ParseExprCXX.cpp:613 #270 0x0000561e287f2ba1 in clang::Parser::ParseCXXIdExpression (this=0x7f132c238a70, isAddressOfOperand=false) at /opt/llvm-project/clang/lib/Parse/ParseExprCXX.cpp:679 #271 0x0000561e287e62d6 in clang::Parser::ParseCastExpression (this=0x7f132c238a70, ParseKind=clang::Parser::AnyCastExpr, isAddressOfOperand=, NotCastExpr=, isTypeCast=, isVectorLiteral=, NotPrimaryExpression=0x0) at /opt/llvm-project/clang/lib/Parse/ParseExpr.cpp:1675 #272 0x0000561e287e6c69 in clang::Parser::ParseCastExpression (this=0x7f132c238a70, ParseKind=(unknown: 0x54fe0978), ParseKind@entry=clang::Parser::AnyCastExpr, isAddressOfOperand=, NotCastExpr=@0x7f1354ff528f: false, isTypeCast=, isVectorLiteral=, NotPrimaryExpression=) at /opt/llvm-project/clang/lib/Parse/ParseExpr.cpp:1169 #273 0x0000561e287e05fc in clang::Parser::ParseCastExpression (ParseKind=clang::Parser::AnyCastExpr, isAddressOfOperand=false, isVectorLiteral=false, NotPrimaryExpression=0x0, this=, isTypeCast=) at /opt/llvm-project/clang/lib/Parse/ParseExpr.cpp:693 #274 clang::Parser::ParseAssignmentExpression (this=, isTypeCast=) at /opt/llvm-project/clang/lib/Parse/ParseExpr.cpp:176 #275 0x0000561e287b47dd in clang::Parser::ParseInitializer (this=0x7f132c238a70) at /opt/llvm-project/clang/include/clang/Parse/Parser.h:2063 #276 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes (this=this@entry=0x7f132c238a70, D=..., TemplateInfo=..., FRI=FRI@entry=0x0) at /opt/llvm-project/clang/lib/Parse/ParseDecl.cpp:2604 #277 0x0000561e287b2104 in clang::Parser::ParseDeclGroup (this=0x7f132c238a70, DS=..., Context=clang::DeclaratorContext::File, Attrs=..., DeclEnd=0x0, FRI=0x0) at /opt/llvm-project/clang/lib/Parse/ParseDecl.cpp:2337 #278 0x0000561e2879806a in clang::Parser::ParseDeclOrFunctionDefInternal (this=this@entry=0x7f132c238a70, Attrs=..., DeclSpecAttrs=..., DS=..., AS=AS@entry=clang::AS_none) at /opt/llvm-project/clang/lib/Parse/Parser.cpp:1244 #279 0x0000561e28797a67 in clang::Parser::ParseDeclarationOrFunctionDefinition (this=this@entry=0x7f132c238a70, Attrs=..., DeclSpecAttrs=..., DS=0x0, AS=AS@entry=clang::AS_none) at /opt/llvm-project/clang/lib/Parse/Parser.cpp:1266 #280 0x0000561e28796d35 in clang::Parser::ParseExternalDeclaration (this=this@entry=0x7f132c238a70, Attrs=..., DeclSpecAttrs=..., DS=DS@entry=0x0) at /opt/llvm-project/clang/lib/Parse/Parser.cpp:1070 #281 0x0000561e287951ca in clang::Parser::ParseTopLevelDecl (this=this@entry=0x7f132c238a70, Result=..., ImportState=@0x7f1354ff67cc: clang::Sema::ModuleImportState::FirstDecl) at /opt/llvm-project/clang/lib/Parse/Parser.cpp:760 #282 0x0000561e28794b3f in clang::Parser::ParseFirstTopLevelDecl (this=0x7f132c238a70, Result=..., ImportState=@0x7f1354ff67cc: clang::Sema::ModuleImportState::FirstDecl) at /opt/llvm-project/clang/lib/Parse/Parser.cpp:607 #283 0x0000561e28790f86 in clang::ParseAST (S=..., PrintStats=false, SkipFunctionBodies=) at /opt/llvm-project/clang/lib/Parse/ParseAST.cpp:162 #284 0x0000561e284ceb67 in clang::FrontendAction::Execute (this=0x7f132c017120) at /opt/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1069 #285 0x0000561e27b53cde in clang::clangd::ParsedAST::build (Filename=..., Inputs=..., CI=..., CompilerInvocationDiags=..., Preamble=std::shared_ptr (empty) = {...}) at /opt/llvm-project/clang-tools-extra/clangd/ParsedAST.cpp:699 #286 0x0000561e27be07ed in clang::clangd::(anonymous namespace)::ASTWorker::generateDiagnostics (this=this@entry=0x561e2b0e9410, Invocation=..., Inputs=..., CIDiags=std::vector of length 0, capacity 0) at /opt/llvm-project/clang-tools-extra/clangd/TUScheduler.cpp:1210 #287 0x0000561e27be027a in clang::clangd::(anonymous namespace)::ASTWorker::updatePreamble(std::unique_ptr >, clang::clangd::ParseInputs, std::shared_ptr, std::vector >, clang::clangd::WantDiagnostics)::$_0::operator()() (this=0x7f1328001350) at /opt/llvm-project/clang-tools-extra/clangd/TUScheduler.cpp:1144 #288 0x0000561e27bdd0a3 in llvm::function_ref::operator()() const (this=) at /opt/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68 #289 clang::clangd::(anonymous namespace)::ASTWorker::runTask(llvm::StringRef, llvm::function_ref) (this=this@entry=0x561e2b0e9410, Name=..., Task=...) at /opt/llvm-project/clang-tools-extra/clangd/TUScheduler.cpp:1324 #290 0x0000561e27bdca85 in clang::clangd::(anonymous namespace)::ASTWorker::run (this=0x561e2b0e9410) at /opt/llvm-project/clang-tools-extra/clangd/TUScheduler.cpp:1458 #291 clang::clangd::(anonymous namespace)::ASTWorker::create(llvm::StringRef, clang::clangd::GlobalCompilationDatabase const&, clang::clangd::TUScheduler::ASTCache&, clang::clangd::TUScheduler::HeaderIncluderCache&, clang::clangd::AsyncTaskRunner*, clang::clangd::Semaphore&, clang::clangd::TUScheduler::Options const&, clang::clangd::ParsingCallbacks&)::$_0::operator()() const (this=) at /opt/llvm-project/clang-tools-extra/clangd/TUScheduler.cpp:822 #292 llvm::detail::UniqueFunctionBase::CallImpl(void*) (CallableAddr=) at /opt/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:221 #293 0x0000561e27d2de92 in llvm::unique_function::operator()() (this=0x561e2b0ee030) at /opt/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:385 #294 clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function)::$_1::operator()() (this=0x561e2b0ee010) at /opt/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:101 #295 _ZZN4llvm6thread18GenericThreadProxyISt5tupleIJZN5clang6clangd15AsyncTaskRunner8runAsyncERKNS_5TwineENS_15unique_functionIFvvEEEE3$_1EEEEvPvENKUlOT_DpOT0_E_clIRSC_JEEEDaSG_SJ_ (F=..., this=) at /opt/llvm-project/llvm/include/llvm/Support/thread.h:43 #296 _ZSt13__invoke_implIvZN4llvm6thread18GenericThreadProxyISt5tupleIJZN5clang6clangd15AsyncTaskRunner8runAsyncERKNS0_5TwineENS0_15unique_functionIFvvEEEE3$_1EEEEvPvEUlOT_DpOT0_E_JRSD_EESG_St14__invoke_otherOT0_DpOT1_ (__args=..., __f=...) at /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:61 #297 _ZSt8__invokeIZN4llvm6thread18GenericThreadProxyISt5tupleIJZN5clang6clangd15AsyncTaskRunner8runAsyncERKNS0_5TwineENS0_15unique_functionIFvvEEEE3$_1EEEEvPvEUlOT_DpOT0_E_JRSD_EENSt15__invoke_resultISG_JDpSI_EE4typeESH_SK_ (__args=..., __fn=...) at /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:96 #298 _ZSt12__apply_implIZN4llvm6thread18GenericThreadProxyISt5tupleIJZN5clang6clangd15AsyncTaskRunner8runAsyncERKNS0_5TwineENS0_15unique_functionIFvvEEEE3$_1EEEEvPvEUlOT_DpOT0_E_RSE_JLm0EEEDcSH_OT0_St16integer_sequenceImJXspT1_EEE (__t=std::tuple containing = {...}, __f=...) at /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/tuple:1854 #299 _ZSt5applyIZN4llvm6thread18GenericThreadProxyISt5tupleIJZN5clang6clangd15AsyncTaskRunner8runAsyncERKNS0_5TwineENS0_15unique_functionIFvvEEEE3$_1EEEEvPvEUlOT_DpOT0_E_RSE_EDcSH_OT0_ (__t=std::tuple containing = {...}, __f=...) at /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/tuple:1865 #300 llvm::thread::GenericThreadProxy)::$_1> >(void*) (Ptr=0x561e2b0ee010) at /opt/llvm-project/llvm/include/llvm/Support/thread.h:41 #301 llvm::thread::ThreadProxy)::$_1> >(void*) (Ptr=0x561e2b0ee010) at /opt/llvm-project/llvm/include/llvm/Support/thread.h:55 #302 0x00007f137e524ac3 in start_thread (arg=) at ./nptl/pthread_create.c:442 #303 0x00007f137e5b6850 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81 ```

As in @coreyzzp's case, OutStr seems to grow indefinitely:

(gdb) p OutStr
$8 = (llvm::SmallVectorImpl<char> &) @0x7f1354ff0580: {
  <llvm::SmallVectorTemplateBase<char, true>> = {
    <llvm::SmallVectorTemplateCommon<char, void>> = {
      <llvm::SmallVectorBase<unsigned long>> = {
        BeginX = 0x7f12140fa010,
        Size = 1755947574,
        Capacity = 2181038079
      }, <No data fields>},
    members of llvm::SmallVectorTemplateBase<char, true>:
    static TakesParamByValue = true
  }, <No data fields>}   

And the first 20 strings are the same or almost the same:

(gdb) x/20s OutStr.BeginX ``` 0x7f12140fa010: "'std::midpoint' has different definitions in different modules; 1 first difference is '_Tp'" 0x7f12140fa06c: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f12140fa0bf: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f12140fa112: " 1 has different definitions in different modules; first difference is this '_Tp'" 0x7f12140fa164: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f12140fa1b7: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f12140fa20a: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f12140fa25d: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f12140fa2b0: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f12140fa303: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f12140fa356: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f12140fa3a9: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f12140fa3fc: "template parameter lists have a different number of parameters ( vs 2)" 0x7f12140fa443: "template parameter has different kinds in different translation units" 0x7f12140fa489: "field declared with incompatible types in different translation units (2 vs. 1)" 0x7f12140fa4da: "external function declared with incompatible types in different translation units (2 vs. 1)" 0x7f12140fa537: "instance variable declared with incompatible types in different translation units (2 vs. 1)" 0x7f12140fa594: "non-type template parameter declared with incompatible types in different translation units ( vs. 2)" 0x7f12140fa5f9: " method 2 has a different number of parameters in different translation units (1 vs. '_Tp')" 0x7f12140fa655: " method 2 has a parameter with a different types in different translation units (1 vs. '_Tp')" ```

Minimal reproducer

test.h (main file)

Doesn't reproduce with a .cpp main file

// The include can be angled or quoted, can contain slashes.
// This file must not exist in the current directory or libcxx include path.
#include "bad_include.h"

#include <numeric>

// Included by <numeric>, also causes the loop if included directly instead of it.
// #include <__numeric/midpoint.h>

// Must use something from std namespace, other namespaces or unqualified names don't work.
int x = std::something;

// These also can cause the loop
// void X() { std::something(); }
// using X = std::something;

compile_commands.json

[
    {
        "command": "clang++-18 -c -o /srcpath/test.o -std=c++20 /srcpath/test.cpp -nostdinc++ -isystem /opt/llvm-project-libcxx/libcxx/include",
        "directory": "/home/vadim-xd/arcadia",
        "file": "/home/vadim-xd/test/test.cpp"
    }
]

opt/llvm-project-libcxx is checked out at dc129d6f715cf83a2072fc8de8b4e4c70bca6935

UPD: the loop doesn't happen with libcxx at c37734d40904ebe9c7cc345aab6be3649b0a903c or newer. Not sure what caused it though and if it could be reproduced with other headers.

HighCommander4 commented 1 month ago

I can reproduce the issue with the testcase from the previous comment.

With an assertions-enabled build, I get an immediate crash with the following assertion:

clang/include/clang/Basic/Diagnostic.h:1550: DiagnosticBuilder clang::DiagnosticsEngine::Report(SourceLocation, unsigned int): Assertion `CurDiagID == std::numeric_limits::max() && "Multiple diagnostics in flight at once!"' failed

HighCommander4 commented 1 month ago

Here is a reduced version of the contents of <__numeric/midpoint.h> which triggers the assertion:

template <bool, class = void> struct enable_if {};
template <class T> struct enable_if<true, T> { typedef T type; };
template <bool B, class T = void> using enable_if_t = typename enable_if<B, T>::type;

template <typename> struct meta { static constexpr int value = 0; };
template <> struct meta<int> { static constexpr int value = 1; };
template <> struct meta<float> { static constexpr int value = 2; };

namespace std {
inline namespace waldo {

template <class T>
constexpr enable_if_t<meta<T>::value == 0, void> midpoint(T) {}

template <class U>
constexpr enable_if_t<meta<U>::value == 1, void> midpoint(U) {}

template <class F>
constexpr enable_if_t<meta<F>::value == 2, void> midpoint(F) {}

} // namespace waldo
} // namespace std
HighCommander4 commented 1 month ago

I was able to trigger the same assertion failure (and in assertions-disabled builds, the same unbounded memory consumption) with clang (no clangd involved).

header.h:

#include "bad_include.h"

template <bool, class = void> struct enable_if {};
template <class T> struct enable_if<true, T> { typedef T type; };
template <bool B, class T = void> using enable_if_t = typename enable_if<B, T>::type;

template <typename> struct meta { static constexpr int value = 0; };
template <> struct meta<int> { static constexpr int value = 1; };
template <> struct meta<float> { static constexpr int value = 2; };

namespace N {
inline namespace inner {

template <class T>
constexpr enable_if_t<meta<T>::value == 0, void> midpoint(T) {}

template <class U>
constexpr enable_if_t<meta<U>::value == 1, void> midpoint(U) {}

template <class F>
constexpr enable_if_t<meta<F>::value == 2, void> midpoint(F) {}

} // namespace inner
} // namespace N

source.cpp:

int x = N::something;

Commands to trigger:

clang++ -Xclang -fallow-pch-with-compiler-errors -c -x c++-header -std=c++20 header.h -o header.h.pch
clang++ -Xclang -fallow-pch-with-compiler-errors -include-pch header.h.pch -c -std=c++20 source.cpp

Output:

header.h:1:10: fatal error: 'bad_include.h' file not found
    1 | #include "bad_include.h"
      |          ^~~~~~~~~~~~~~~
clang++: clang/include/clang/Basic/Diagnostic.h:1550: DiagnosticBuilder clang::DiagnosticsEngine::Report(SourceLocation, unsigned int): Assertion `CurDiagID == std::numeric_limits<unsigned>::max() && "Multiple diagnostics in flight at once!"' 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: clang++ -Xclang -fallow-pch-with-compiler-errors -include-pch header.h.pch -c -std=c++20 source.cpp
1.      source.cpp:1:21: current parser token ';'
 #0 0x00007f4514ff0a3d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) llvm/lib/Support/Unix/Signals.inc:723:11
 #1 0x00007f4514ff0f2b PrintStackTraceSignalHandler(void*) llvm/lib/Support/Unix/Signals.inc:798:1
 #2 0x00007f4514feefb6 llvm::sys::RunSignalHandlers() llvm/lib/Support/Signals.cpp:105:5
 #3 0x00007f4514ff02ce llvm::sys::CleanupOnSignal(unsigned long) llvm/lib/Support/Unix/Signals.inc:368:1
 #4 0x00007f4514ea2d07 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) llvm/lib/Support/CrashRecoveryContext.cpp:0:7
 #5 0x00007f4514ea30a5 CrashRecoverySignalHandler(int) llvm/lib/Support/CrashRecoveryContext.cpp:391:1
 #6 0x00007f451da39140 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x13140)
 #7 0x00007f4514737ce1 raise ./signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #8 0x00007f4514721537 abort ./stdlib/abort.c:81:7
 #9 0x00007f451472140f get_sysdep_segment_value ./intl/loadmsgcat.c:509:8
#10 0x00007f451472140f _nl_load_domain ./intl/loadmsgcat.c:970:34
#11 0x00007f4514730662 (/lib/x86_64-linux-gnu/libc.so.6+0x31662)
#12 0x00007f450ff785d7 clang::DiagnosticsEngine::Report(clang::SourceLocation, unsigned int) clang/include/clang/Basic/Diagnostic.h:0:3
#13 0x00007f4510825875 clang::ODRDiagsEmitter::Diag(clang::SourceLocation, unsigned int) const clang/include/clang/AST/ODRDiagsEmitter.h:133:18
#14 0x00007f4510821adc clang::ODRDiagsEmitter::diagnoseMismatch(clang::FunctionDecl const*, clang::FunctionDecl const*) const::$_0::operator()(clang::SourceLocation, clang::SourceRange, clang::ODRDiagsEmitter::diagnoseMismatch(clang::FunctionDecl const*, clang::FunctionDecl const*) const::ODRFunctionDifference) const clang/lib/AST/ODRDiagsEmitter.cpp:1683:12
#15 0x00007f4510821329 clang::ODRDiagsEmitter::diagnoseMismatch(clang::FunctionDecl const*, clang::FunctionDecl const*) const clang/lib/AST/ODRDiagsEmitter.cpp:1738:17
#16 0x00007f4518f1edcf clang::ASTReader::diagnoseOdrViolations() clang/lib/Serialization/ASTReader.cpp:10100:11
#17 0x00007f4518f1fbbc clang::ASTReader::FinishedDeserializing() clang/lib/Serialization/ASTReader.cpp:10222:5
#18 0x00007f4518f32f2c clang::ExternalASTSource::Deserializing::~Deserializing() clang/include/clang/AST/ExternalASTSource.h:87:5
#19 0x00007f4518f16bd7 clang::ASTReader::FindExternalVisibleDeclsByName(clang::DeclContext const*, clang::DeclarationName) clang/lib/Serialization/ASTReader.cpp:8030:1
#20 0x00007f45103869a9 clang::DeclContext::lookup(clang::DeclarationName) const clang/lib/AST/DeclBase.cpp:1871:60
#21 0x00007f4510360657 clang::NamespaceDecl::isRedundantInlineQualifierFor(clang::DeclarationName) const clang/include/clang/AST/Decl.h:644:14
#22 0x00007f451034d70e clang::NamedDecl::printNestedNameSpecifier(llvm::raw_ostream&, clang::PrintingPolicy const&) const clang/lib/AST/Decl.cpp:1747:9
#23 0x00007f451034d34a clang::NamedDecl::printQualifiedName(llvm::raw_ostream&, clang::PrintingPolicy const&) const clang/lib/AST/Decl.cpp:1694:3
#24 0x00007f451034ddde clang::NamedDecl::getNameForDiagnostic(llvm::raw_ostream&, clang::PrintingPolicy const&, bool) const clang/lib/AST/Decl.cpp:1823:5
#25 0x00007f4510353508 clang::FunctionDecl::getNameForDiagnostic(llvm::raw_ostream&, clang::PrintingPolicy const&, bool) const clang/lib/AST/Decl.cpp:3079:14
#26 0x00007f450ffd149d clang::FormatASTNodeDiagnosticArgument(clang::DiagnosticsEngine::ArgumentKind, long, llvm::StringRef, llvm::StringRef, llvm::ArrayRef<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>>, llvm::SmallVectorImpl<char>&, void*, llvm::ArrayRef<long>) clang/lib/AST/ASTDiagnostic.cpp:462:7
#27 0x00007f451889bea1 clang::DiagnosticsEngine::ConvertArgToString(clang::DiagnosticsEngine::ArgumentKind, long, llvm::StringRef, llvm::StringRef, llvm::ArrayRef<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>>, llvm::SmallVectorImpl<char>&, llvm::ArrayRef<long>) const clang/include/clang/Basic/Diagnostic.h:887:3
#28 0x00007f45188975a8 clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl<char>&) const clang/lib/Basic/Diagnostic.cpp:1066:7
#29 0x00007f45188964ec clang::Diagnostic::FormatDiagnostic(llvm::SmallVectorImpl<char>&) const clang/lib/Basic/Diagnostic.cpp:802:1
#30 0x00007f4519cea18a clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) clang/lib/Frontend/TextDiagnosticPrinter.cpp:119:29
#31 0x00007f45188aa3d2 clang::DiagnosticIDs::EmitDiag(clang::DiagnosticsEngine&, clang::DiagnosticIDs::Level) const clang/lib/Basic/DiagnosticIDs.cpp:837:7
#32 0x00007f45188aa1f4 clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const clang/lib/Basic/DiagnosticIDs.cpp:829:3
#33 0x00007f451889b359 clang::DiagnosticsEngine::ProcessDiag() clang/include/clang/Basic/Diagnostic.h:1042:5
#34 0x00007f4518896319 clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) clang/lib/Basic/Diagnostic.cpp:546:13
#35 0x00007f450ff7902f clang::DiagnosticBuilder::Emit() clang/include/clang/Basic/Diagnostic.h:1325:28
#36 0x00007f450ff78519 clang::DiagnosticBuilder::~DiagnosticBuilder() clang/include/clang/Basic/Diagnostic.h:1366:26
#37 0x00007f451082137c clang::ODRDiagsEmitter::diagnoseMismatch(clang::FunctionDecl const*, clang::FunctionDecl const*) const clang/lib/AST/ODRDiagsEmitter.cpp:1742:15
#38 0x00007f4518f1edcf clang::ASTReader::diagnoseOdrViolations() clang/lib/Serialization/ASTReader.cpp:10100:11
#39 0x00007f4518f1fbbc clang::ASTReader::FinishedDeserializing() clang/lib/Serialization/ASTReader.cpp:10222:5
#40 0x00007f4518f32f2c clang::ExternalASTSource::Deserializing::~Deserializing() clang/include/clang/AST/ExternalASTSource.h:87:5
#41 0x00007f451905c1d2 clang::ASTReader::ReadDeclRecord(clang::GlobalDeclID) clang/lib/Serialization/ASTReaderDecl.cpp:4175:1
#42 0x00007f4518f0e46b clang::ASTReader::GetDecl(clang::GlobalDeclID) clang/lib/Serialization/ASTReader.cpp:7816:5
#43 0x00007f4518f16d98 clang::ASTReader::completeVisibleDeclsMap(clang::DeclContext const*) clang/lib/Serialization/ASTReader.cpp:8043:37
#44 0x00007f450dc4b5c8 clang::DeclContext::lookups() const clang/include/clang/AST/DeclLookups.h:79:29
#45 0x00007f450dc3a791 (anonymous namespace)::LookupVisibleHelper::lookupInDeclContext(clang::DeclContext*, clang::LookupResult&, bool, bool) clang/lib/Sema/SemaLookup.cpp:4225:10
#46 0x00007f450dc2a08f (anonymous namespace)::LookupVisibleHelper::lookupVisibleDecls(clang::Sema&, clang::DeclContext*, clang::Sema::LookupNameKind, bool) clang/lib/Sema/SemaLookup.cpp:4169:3
#47 0x00007f450dc29f32 clang::Sema::LookupVisibleDecls(clang::DeclContext*, clang::Sema::LookupNameKind, clang::VisibleDeclConsumer&, bool, bool, bool) clang/lib/Sema/SemaLookup.cpp:4475:1
#48 0x00007f450dc2d31a clang::Sema::makeTypoCorrectionConsumer(clang::DeclarationNameInfo const&, clang::Sema::LookupNameKind, clang::Scope*, clang::CXXScopeSpec*, clang::CorrectionCandidateCallback&, clang::DeclContext*, bool, clang::ObjCObjectPointerType const*, bool) clang/lib/Sema/SemaLookup.cpp:5323:3
#49 0x00007f450dc2f0fe clang::Sema::CorrectTypoDelayed(clang::DeclarationNameInfo const&, clang::Sema::LookupNameKind, clang::Scope*, clang::CXXScopeSpec*, clang::CorrectionCandidateCallback&, std::function<void (clang::TypoCorrection const&)>, std::function<clang::ActionResult<clang::Expr*, true> (clang::Sema&, clang::TypoExpr*, clang::TypoCorrection)>, clang::Sema::CorrectTypoKind, clang::DeclContext*, bool, clang::ObjCObjectPointerType const*) clang/lib/Sema/SemaLookup.cpp:5554:18
#50 0x00007f450d60eb52 clang::Sema::DiagnoseEmptyLookup(clang::Scope*, clang::CXXScopeSpec&, clang::LookupResult&, clang::CorrectionCandidateCallback&, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::DeclContext*, clang::TypoExpr**) clang/lib/Sema/SemaExpr.cpp:2537:12
#51 0x00007f450d606741 clang::Sema::ActOnIdExpression(clang::Scope*, clang::CXXScopeSpec&, clang::SourceLocation, clang::UnqualifiedId&, bool, bool, clang::CorrectionCandidateCallback*, bool, clang::Token*) clang/lib/Sema/SemaExpr.cpp:2826:9
#52 0x00007f450e7a190b clang::Parser::tryParseCXXIdExpression(clang::CXXScopeSpec&, bool, clang::Token&) clang/lib/Parse/ParseExprCXX.cpp:658:17
#53 0x00007f450e7a330a clang::Parser::ParseCXXIdExpression(bool) clang/lib/Parse/ParseExprCXX.cpp:751:7
#54 0x00007f450e78c94e clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) clang/lib/Parse/ParseExpr.cpp:1683:11
#55 0x00007f450e78a756 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) clang/lib/Parse/ParseExpr.cpp:1198:18
#56 0x00007f450e784429 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) clang/lib/Parse/ParseExpr.cpp:712:20
#57 0x00007f450e782921 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) clang/lib/Parse/ParseExpr.cpp:182:20
#58 0x00007f450e73524a clang::Parser::ParseInitializer() clang/include/clang/Parse/Parser.h:2115:14
#59 0x00007f450e71a163 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) clang/lib/Parse/ParseDecl.cpp:2764:25
#60 0x00007f450e7186f9 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) clang/lib/Parse/ParseDecl.cpp:2479:9
#61 0x00007f450e85bb3c clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) clang/lib/Parse/Parser.cpp:1249:10
#62 0x00007f450e85b01e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) clang/lib/Parse/Parser.cpp:1271:12
#63 0x00007f450e85a89a clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) clang/lib/Parse/Parser.cpp:1074:14
#64 0x00007f450e8586dc clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) clang/lib/Parse/Parser.cpp:763:12
#65 0x00007f450e857d80 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) clang/lib/Parse/Parser.cpp:608:8
#66 0x00007f450e6f212b clang::ParseAST(clang::Sema&, bool, bool) clang/lib/Parse/ParseAST.cpp:162:15
#67 0x00007f4519c5d881 clang::ASTFrontendAction::ExecuteAction() clang/lib/Frontend/FrontendAction.cpp:1195:1
#68 0x00007f451d62e7e6 clang::CodeGenAction::ExecuteAction() clang/lib/CodeGen/CodeGenAction.cpp:1147:5
#69 0x00007f4519c5d27c clang::FrontendAction::Execute() clang/lib/Frontend/FrontendAction.cpp:1082:7
#70 0x00007f4519b53b89 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) clang/lib/Frontend/CompilerInstance.cpp:1061:23
#71 0x00007f451da0c73e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:280:8
#72 0x000055a18ab0d2a1 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) clang/tools/driver/cc1_main.cpp:232:13
#73 0x000055a18aaffc02 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) clang/tools/driver/driver.cpp:215:5
#74 0x000055a18ab006ad clang_main(int, char**, llvm::ToolContext const&)::$_0::operator()(llvm::SmallVectorImpl<char const*>&) const clang/tools/driver/driver.cpp:355:7
#75 0x000055a18ab0067d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::$_0>(long, llvm::SmallVectorImpl<char const*>&) llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5
#76 0x00007f45194c65b1 llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::operator()(llvm::SmallVectorImpl<char const*>&) const llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5
#77 0x00007f45194c0638 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 clang/lib/Driver/Job.cpp:440:34
#78 0x00007f45194c0605 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/include/llvm/ADT/STLFunctionalExtras.h:45:5
#79 0x00007f4514e8e829 llvm::function_ref<void ()>::operator()() const llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5
#80 0x00007f4514ea2afa llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) llvm/lib/Support/CrashRecoveryContext.cpp:427:3
#81 0x00007f45194bff9b clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const clang/lib/Driver/Job.cpp:440:7
#82 0x00007f451944061f clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const clang/lib/Driver/Compilation.cpp:199:15
#83 0x00007f4519440827 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const clang/lib/Driver/Compilation.cpp:253:13
#84 0x00007f4519461f92 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) clang/lib/Driver/Driver.cpp:1950:7
#85 0x000055a18aaff6db clang_main(int, char**, llvm::ToolContext const&) clang/tools/driver/driver.cpp:391:9
#86 0x000055a18ab32b35 main tools/clang/tools/driver/clang-driver.cpp:17:3
#87 0x00007f4514722d0a __libc_start_main ./csu/../csu/libc-start.c:308:16
#88 0x000055a18aafe3fa _start (clang+++0x3c3fa)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 19.0.0git
Target: x86_64-unknown-linux-gnu
Thread model: posix
Build config: +unoptimized, +assertions
clang++: note: diagnostic msg: Error generating preprocessed source(s).
llvmbot commented 1 month ago

@llvm/issue-subscribers-clang-frontend

Author: ZHU ZHIPU (coreyzzp)

version : llvmorg-17.0.3 Recently, when using clangd in vscode remote, once a certain file is encountered, the memory will explode, eventually causing the entire machine to go out of memory (clangd consumes more than 64G of memory). Below is the stack (using the release version, compiled with -g) ``` #0 0x00007f4d2d1a8233 in _int_malloc () from /lib64/libc.so.6 #1 0x00007f4d2d1ab10c in malloc () from /lib64/libc.so.6 #2 0x0000000000a2b2d8 in llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long) () #3 0x0000000000f35070 in llvm::SmallVectorTemplateCommon<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, void>::grow_pod (TSize=16, MinSize=<optimized out>, this=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:140 #4 llvm::SmallVectorTemplateBase<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, true>::grow (MinSize=<optimized out>, this=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:529 #5 llvm::SmallVectorTemplateCommon<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, void>::reserveForParamAndGetAddressImpl<llvm::SmallVectorTemplateBase<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, true> > (N=1, Elt=<synthetic pointer>..., This=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:246 #6 llvm::SmallVectorTemplateBase<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, true>::reserveForParamAndGetAddress (N=1, Elt=<synthetic pointer>..., this=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:541 #7 llvm::SmallVectorTemplateBase<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>, true>::push_back (Elt=..., this=0x7f4d25fe3710) at /llvmorg-17.0.3/llvm/include/llvm/ADT/SmallVector.h:566 #8 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a4068 <(anonymous namespace)::StaticDiagInfoDescriptions+249544> "'", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1142 #9 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #10 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a3d23 <(anonymous namespace)::StaticDiagInfoDescriptions+248707> ")' clause%select{s|}1", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #11 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #12 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a3cf0 <(anonymous namespace)::StaticDiagInfoDescriptions+248656> " cannot be mixed with '%0(%select{sink:vec|source}1)' clause%select{s|}1", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #13 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #14 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a3cdb <(anonymous namespace)::StaticDiagInfoDescriptions+248635> ")' clause%select{|s}1 cannot be mixed with '%0(%select{sink:vec|source}1)' clause%select{s|}1", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #15 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #16 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a2e66 <(anonymous namespace)::StaticDiagInfoDescriptions+244934> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #17 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #18 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a138a <(anonymous namespace)::StaticDiagInfoDescriptions+238058> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #19 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #20 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x6a08f0 <(anonymous namespace)::StaticDiagInfoDescriptions+235344> " type", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #21 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #22 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69fb28 <(anonymous namespace)::StaticDiagInfoDescriptions+231816> ", not %0", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #23 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #24 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69f1b4 <(anonymous namespace)::StaticDiagInfoDescriptions+229396> " because assigning method's 2nd parameter of type %0 is not an Objective-C pointer type", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #25 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #26 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69ea67 <(anonymous namespace)::StaticDiagInfoDescriptions+227527> " element must have Objective-C object return type instead of %0", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #27 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #28 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69e6bf <(anonymous namespace)::StaticDiagInfoDescriptions+226591> " %3", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #29 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #30 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69e660 <(anonymous namespace)::StaticDiagInfoDescriptions+226496> " declaration conflicts with previous %select{|direct }2declaration of %select{method|property}1 %3", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #31 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #32 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69e3eb <(anonymous namespace)::StaticDiagInfoDescriptions+225867> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #33 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #34 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69c9ab <(anonymous namespace)::StaticDiagInfoDescriptions+219147> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #35 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #36 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69bde6 <(anonymous namespace)::StaticDiagInfoDescriptions+216134> "", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #37 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #38 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69b4bd <(anonymous namespace)::StaticDiagInfoDescriptions+213789> " follows declaration in %select{the global module|module %4}3", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #39 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #40 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69b239 <(anonymous namespace)::StaticDiagInfoDescriptions+213145> " method %0 not found ; did you mean %2?", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #41 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #42 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69ad1b <(anonymous namespace)::StaticDiagInfoDescriptions+211835> ", but function has %select{non-const lvalue|rvalue}2 ref-qualifier", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #43 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #44 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69aa5c <(anonymous namespace)::StaticDiagInfoDescriptions+211132> " %2?", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #45 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #46 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x69a6ec <(anonymous namespace)::StaticDiagInfoDescriptions+210252> " integers and enum types, but was given %2%select{| whose underlying type is %4}3", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 ....... ....... ....... something like FormatDiagnostic ....... ....... ....... ....... #224 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67f46c <(anonymous namespace)::StaticDiagInfoDescriptions+99020> " found %select{%select{no super class|super class with type %5}4|instance variable '%4' access control is %select{|@private|@protected|@public|@package}5}3", DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #225 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #226 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67f30c <(anonymous namespace)::StaticDiagInfoDescriptions+98668> " has different definitions in different modules; first difference is this %select{||||static assert|field|method|type alias|typedef|data member|friend declaration|function template|method|instance var"..., DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #227 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #228 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67f1e8 <(anonymous namespace)::StaticDiagInfoDescriptions+98376> " found %select{end of class|public access specifier|private access specifier|protected access specifier|static assert|field|method|type alias|typedef|data member|friend declaration|function template|m"..., DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #229 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #230 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67f064 <(anonymous namespace)::StaticDiagInfoDescriptions+97988> " found %select{%select{method %5|constructor|destructor}4 that has %6 parameter%s6|%select{method %5|constructor|destructor}4 with %ordinal6 parameter of type %7%select{| decayed from %9}8|%select{met"..., DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #231 0x0000000000f35375 in HandleSelectModifier (OutStr=..., ArgumentLen=<optimized out>, Argument=<optimized out>, ValNo=<optimized out>, DInfo=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:628 #232 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67eeea <(anonymous namespace)::StaticDiagInfoDescriptions+97610> " first difference is %select{return type is %4|%ordinal4 parameter with name %5|%ordinal4 parameter with type %5%select{| decayed from %7}6|%ordinal4 parameter with%select{out|}5 a default argument|%o"..., DiagEnd=<optimized out>, OutStr=...) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:1001 #233 0x0000000001de8f76 in clang::clangd::fillNonLocationData (DiagLevel=clang::DiagnosticsEngine::Error, Info=..., D=...) at /llvmorg-17.0.3/clang-tools-extra/clangd/Diagnostics.cpp:664 #234 0x0000000001dea974 in operator() (__closure=__closure@entry=0x7f4d25ff66e0, D=...) at /llvmorg-17.0.3/clang-tools-extra/clangd/Diagnostics.cpp:720 #235 0x0000000001df8222 in clang::clangd::StoreDiags::HandleDiagnostic (this=0x7f4d25ff9be0, DiagLevel=<optimized out>, Info=...) at /opt/gcc-11.1.0/include/c++/11.1.0/optional:440 #236 0x0000000000f3a572 in clang::DiagnosticIDs::EmitDiag (DiagLevel=clang::DiagnosticIDs::Error, Diag=..., this=0x7f4d1c01e1f0) at /llvmorg-17.0.3/clang/lib/Basic/DiagnosticIDs.cpp:823 #237 clang::DiagnosticIDs::ProcessDiag (this=this@entry=0x7f4d1c01e1f0, Diag=...) at /llvmorg-17.0.3/clang/lib/Basic/DiagnosticIDs.cpp:815 #238 0x0000000000f33f1b in clang::DiagnosticsEngine::ProcessDiag (this=0x7f4d1c001990) at /llvmorg-17.0.3/clang/include/clang/Basic/Diagnostic.h:1037 #239 clang::DiagnosticsEngine::EmitCurrentDiagnostic (this=0x7f4d1c001990, Force=<optimized out>) at /llvmorg-17.0.3/clang/lib/Basic/Diagnostic.cpp:545 #240 0x0000000000b61590 in clang::DiagnosticBuilder::~DiagnosticBuilder() () #241 0x0000000000e0f1f4 in clang::ODRDiagsEmitter::diagnoseMismatch(clang::FunctionDecl const*, clang::FunctionDecl const*) const () #242 0x0000000002b5b877 in clang::ASTReader::diagnoseOdrViolations() [clone .localalias] () #243 0x0000000002b5e761 in clang::ASTReader::FinishedDeserializing() [clone .part.0] () #244 0x0000000002bbac65 in clang::ASTReader::ReadDeclRecord(unsigned int) () #245 0x0000000002b4d6c9 in clang::ASTReader::GetDecl(unsigned int) [clone .localalias] () #246 0x0000000002b665c3 in clang::ASTReader::completeVisibleDeclsMap(clang::DeclContext const*) [clone .part.0] () #247 0x00000000018c2e1e in (anonymous namespace)::LookupVisibleHelper::lookupInDeclContext(clang::DeclContext*, clang::LookupResult&, bool, bool) () #248 0x00000000018c5282 in clang::Sema::LookupVisibleDecls(clang::DeclContext*, clang::Sema::LookupNameKind, clang::VisibleDeclConsumer&, bool, bool, bool) [clone .localalias] () #249 0x00000000018cf4f4 in clang::Sema::makeTypoCorrectionConsumer(clang::DeclarationNameInfo const&, clang::Sema::LookupNameKind, clang::Scope*, clang::CXXScopeSpec*, clang::CorrectionCandidateCallback&, clang::DeclContext*, bool, clang::ObjCObjectPointerType const*, bool) [clone .localalias] () #250 0x00000000018d0c1d in clang::Sema::CorrectTypo(clang::DeclarationNameInfo const&, clang::Sema::LookupNameKind, clang::Scope*, clang::CXXScopeSpec*, clang::CorrectionCandidateCallback&, clang::Sema::CorrectTypoKind, clang::DeclContext*, bool, clang::ObjCObjectPointerType const*, bool) () #251 0x0000000001536b02 in clang::Sema::DiagnoseUnknownTypeName(clang::IdentifierInfo*&, clang::SourceLocation, clang::Scope*, clang::CXXScopeSpec*, clang::OpaquePtr<clang::QualType>&, bool) () #252 0x0000000002a1a27d in clang::Parser::ParseImplicitInt(clang::DeclSpec&, clang::CXXScopeSpec*, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) [clone .localalias] () #253 0x0000000002a1e49c in clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) [clone .localalias] () #254 0x0000000002af8dad in clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) [clone .localalias] () #255 0x0000000002af9e9f in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) [clone .part.0] () #256 0x0000000002b00676 in clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) [clone .localalias] () #257 0x0000000002b018da in clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) [clone .localalias] () #258 0x00000000029fe3ca in clang::ParseAST(clang::Sema&, bool, bool) [clone .localalias] () #259 0x000000000116f5f9 in clang::FrontendAction::Execute() () #260 0x0000000001ee75fd in clang::clangd::ParsedAST::build (Filename=..., Inputs=..., CI=..., CompilerInvocationDiags=..., Preamble=...) at /llvmorg-17.0.3/clang-tools-extra/clangd/ParsedAST.cpp:669 #261 0x0000000001f5d462 in clang::clangd::(anonymous namespace)::ASTWorker::generateDiagnostics (this=0x3946950, Invocation=..., Inputs=..., CIDiags=...) at /opt/gcc-11.1.0/include/c++/11.1.0/bits/basic_string.h:912 #262 0x0000000001f5dd83 in operator() (__closure=0x7f4cf80022d0) at /opt/gcc-11.1.0/include/c++/11.1.0/bits/unique_ptr.h:172 #263 0x0000000001f56965 in llvm::unique_function<void ()>::operator()() (this=0x3946bb0) at /llvmorg-17.0.3/llvm/include/llvm/ADT/FunctionExtras.h:382 #264 llvm::function_ref<void ()>::callback_fn<llvm::unique_function<void ()> >(long) (callable=60058544) at /llvmorg-17.0.3/llvm/include/llvm/ADT/STLFunctionalExtras.h:45 #265 llvm::function_ref<void ()>::operator()() const (this=<synthetic pointer>) at /llvmorg-17.0.3/llvm/include/llvm/ADT/STLFunctionalExtras.h:68 #266 clang::clangd::(anonymous namespace)::ASTWorker::runTask(llvm::StringRef, llvm::function_ref<void()>) (this=this@entry=0x3946950, Name=..., Task=...) at /llvmorg-17.0.3/clang-tools-extra/clangd/TUScheduler.cpp:1324 #267 0x0000000001f58439 in clang::clangd::(anonymous namespace)::ASTWorker::run (this=0x3946950) at /llvmorg-17.0.3/clang-tools-extra/clangd/TUScheduler.cpp:1458 #268 0x0000000002106f25 in llvm::unique_function<void ()>::operator()() (this=0x392abc0) at /llvmorg-17.0.3/llvm/include/llvm/ADT/FunctionExtras.h:382 #269 operator() (__closure=0x392aba0) at /llvmorg-17.0.3/clang-tools-extra/clangd/support/Threading.cpp:101 #270 operator()<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()>&> (F=..., __closure=<optimized out>) at /llvmorg-17.0.3/llvm/include/llvm/Support/thread.h:43 #271 std::__invoke_impl<void, llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()>&> (__f=...) at /opt/gcc-11.1.0/include/c++/11.1.0/bits/invoke.h:61 #272 std::__invoke<llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()>&> (__fn=...) at /opt/gcc-11.1.0/include/c++/11.1.0/bits/invoke.h:96 #273 std::__apply_impl<llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> >&, 0> (__t=..., __f=...) at /opt/gcc-11.1.0/include/c++/11.1.0/tuple:1806 #274 std::apply<llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> >&> (__t=..., __f=...) at /opt/gcc-11.1.0/include/c++/11.1.0/tuple:1817 #275 llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > > (Ptr=0x392aba0) at /llvmorg-17.0.3/llvm/include/llvm/Support/thread.h:41 #276 llvm::thread::ThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void *) (Ptr=0x392aba0) at /llvmorg-17.0.3/llvm/include/llvm/Support/thread.h:55 #277 0x00007f4d2e258e25 in start_thread () from /lib64/libpthread.so.0 #278 0x00007f4d2d22335d in clone () from /lib64/libc.so.6 ``` the input to `clang::Diagnostic::FormatDiagnostic` look like this: ``` f 232 #232 clang::Diagnostic::FormatDiagnostic (this=0x7f4d25ff6930, DiagStr=0x67eeea <(anonymous namespace)::StaticDiagInfoDescriptions+97610> " first difference is %select{return type is %4|%ordinal4 parameter with name %5|%ordinal4 parameter with type %5%select{| decayed from %7}6|%ordinal4 parameter with%select{out|}5 a default argument|%o"..., DiagEnd=<optimized out>, OutStr=...) at /source/install/llvm/llvm.git/clang/lib/Basic/Diagnostic.cpp:1001 1001 HandleSelectModifier(*this, Val, Argument, ArgumentLen, OutStr); (gdb) p DiagStr $5 = 0x67eeea <(anonymous namespace)::StaticDiagInfoDescriptions+97610> " first difference is %select{return type is %4|%ordinal4 parameter with name %5|%ordinal4 parameter with type %5%select{| decayed from %7}6|%ordinal4 parameter with%select{out|}5 a default argument|%o"... (gdb) printf "%s\n", DiagStr first difference is %select{return type is %4|%ordinal4 parameter with name %5|%ordinal4 parameter with type %5%select{| decayed from %7}6|%ordinal4 parameter with%select{out|}5 a default argument|%ordinal4 parameter with a default argument|function body}3 (gdb) ``` and the `OutStr` contains the hugh memory ``` (gdb) p OutStr $24 = (llvm::SmallVectorImpl<char> &) @0x7f4d25ff6500: { <llvm::SmallVectorTemplateBase<char, true>> = { <llvm::SmallVectorTemplateCommon<char, void>> = { <llvm::SmallVectorBase<unsigned long>> = { BeginX = 0x7f48d43fa010, Size = 4511505832, Capacity = 8724152319 }, <No data fields>}, members of llvm::SmallVectorTemplateBase<char, true>: static TakesParamByValue = true }, <No data fields>} (gdb) ``` the content of `OutStr` ``` (gdb) x /20xs (0x7f48d43fa010) 0x7f48d43fa010: "'std::midpoint' has different definitions in different modules; 1 first difference is '_Tp'" 0x7f48d43fa06c: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa0bf: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa112: " 1 has different definitions in different modules; first difference is this '_Tp'" 0x7f48d43fa164: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa1b7: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa20a: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa25d: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa2b0: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa303: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa356: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa3a9: " has different definitions in different modules; first difference is 1 found '_Tp'" 0x7f48d43fa3fc: "template parameter lists have a different number of parameters ( vs 2)" 0x7f48d43fa443: "template parameter has different kinds in different translation units" 0x7f48d43fa489: "field declared with incompatible types in different translation units (2 vs. 1)" 0x7f48d43fa4da: "external function declared with incompatible types in different translation units (2 vs. 1)" 0x7f48d43fa537: "instance variable declared with incompatible types in different translation units (2 vs. 1)" 0x7f48d43fa594: "non-type template parameter declared with incompatible types in different translation units ( vs. 2)" 0x7f48d43fa5f9: " method 2 has a different number of parameters in different translation units (1 vs. '_Tp')" 0x7f48d43fa655: " method 2 has a parameter with a different types in different translation units (1 vs. '_Tp')" (gdb) x /20xs (0x7f48d43fa010 + 4511505832 - 200) 0x7f49e127bcf0: "ncurrent" 0x7f49e127bcf9: "expected in OpenMP clause '2'" 0x7f49e127bd18: "modifier '' cannot be used along with modifier '2'" 0x7f49e127bd4b: "mapping of union members is not allowed" 0x7f49e127bd73: "incorrect reduction identifier, expected one of '+', '-', '*', '&', '" 0x7f49e127bdb9: "" 0x7f49e127bdba: "" 0x7f49e127bdbb: "" 0x7f49e127bdbc: "" 0x7f49e127bdbd: "" 0x7f49e127bdbe: "" ```
HighCommander4 commented 1 month ago

This is a regression; the issue was not present in clang 16.

HighCommander4 commented 1 month ago

The regression was introduced by https://github.com/llvm/llvm-project/commit/bc73ef0031b50f7443615fef614fb4ecaaa4bd11.

cc @zygoloid

(This regression window was brought to you by manyclangs.)

HighCommander4 commented 2 weeks ago

Given that this bug is causing pretty bad behaviour in clangd, perhaps we could employ a temporary fix while the underlying issue is investigated, where we keep the assert is assertions-enabled builds, but arrange for the runtime behaviour in assertions-disabled builds to not be a stack overflow under the conditions that would trigger the assert?

zygoloid commented 2 weeks ago

The fundamental issue here is that it's not safe for the deserialization code to produce diagnostics, because the current diagnostic is a single shared resource and the deserialization code can be called at almost any time, including from the middle of emitting a diagnostic.

Probably the right thing to do is to build a queue of deserialization diagnostics when the deserialization code wants to report an error, and defer emitting them until after the current diagnostic finishes (if any) or the Deserialization step ends (if not).