Open coreyzzp opened 9 months ago
@llvm/issue-subscribers-clangd
Author: ZHU ZHIPU (coreyzzp)
@llvm/issue-subscribers-clang-modules
Author: ZHU ZHIPU (coreyzzp)
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).
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
Hi. I have the same or very similar issue with clangd 18 (llvmorg-18.1.8
),
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
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.
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
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
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).
@llvm/issue-subscribers-clang-frontend
Author: ZHU ZHIPU (coreyzzp)
This is a regression; the issue was not present in clang 16.
The regression was introduced by https://github.com/llvm/llvm-project/commit/bc73ef0031b50f7443615fef614fb4ecaaa4bd11.
cc @zygoloid
(This regression window was brought to you by manyclangs.)
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?
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).
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)
the input to
clang::Diagnostic::FormatDiagnostic
look like this:and the
OutStr
contains the hugh memorythe content of
OutStr