Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modernize-loop-convert check triggers "Multiple diagnostics in flight at once!" assertion #156

Closed
hokein opened this issue Sep 17, 2019 · 0 comments
Labels
bug Something isn't working

Comments

@hokein
Copy link
Contributor

hokein commented Sep 17, 2019

Reproduce code:

#include <map>
struct LabelInfo {
  int a;
  bool b, c;
  int d;
};

void f() {
  std::map<int, LabelInfo> label_info_map;
   for (auto label_it = label_info_map.begin();
             label_it != label_info_map.end(); ++label_it) {
      const LabelInfo& label_info = label_it->second;
   }
}

Crash stack:

assert.h assertion failed at llvm/tools/clang/include/clang/Basic/Diagnostic.h:1293 in clang::DiagnosticBuilder clang::DiagnosticsEngine::Report(clang::SourceLocation, unsigned int): CurDiagID == std::numeric_limits<unsigned>::max() && "Multiple diagnostics in flight at once!"
*** Check failure stack trace: ***
    @     0x560c2e128722  absl::logging_internal::LogMessage::DieIfFatal()
    @     0x560c2e1276d4  absl::logging_internal::LogMessage::Flush()
    @     0x560c2e129f49  absl::logging_internal::LogMessageFatal::~LogMessageFatal()
    @     0x560c2e1260c6  __assert_fail
    @     0x560c2d958793  (anonymous namespace)::ItaniumRecordLayoutBuilder::CheckFieldPadding()
    @     0x560c2d957a40  (anonymous namespace)::ItaniumRecordLayoutBuilder::LayoutField()
    @     0x560c2d952eab  (anonymous namespace)::ItaniumRecordLayoutBuilder::LayoutFields()
    @     0x560c2d94bbe7  clang::ASTContext::getASTRecordLayout()
    @     0x560c2d94a72f  clang::ASTContext::getASTRecordLayout()
    @     0x560c2d700c6c  clang::ASTContext::getTypeInfoImpl()
    @     0x560c2d70200e  clang::ASTContext::getTypeInfo()
    @     0x560c2d700b9d  clang::ASTContext::getTypeInfoImpl()
    @     0x560c2d70200e  clang::ASTContext::getTypeInfo()
    @     0x560c2c668345  clang::tidy::modernize::LoopConvertCheck::doConversion()
    @     0x560c2c669af6  clang::tidy::modernize::LoopConvertCheck::check()
    @     0x560c2d6a58fc  clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch()
    @     0x560c2d6d1337  clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches()
    @     0x560c2d6a5051  clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter()
    @     0x560c2d6b6ef9  clang::RecursiveASTVisitor<>::TraverseCompoundStmt()
    @     0x560c2d6b57ee  clang::RecursiveASTVisitor<>::TraverseStmt()
    @     0x560c2d6d10a9  clang::RecursiveASTVisitor<>::TraverseFunctionHelper()
    @     0x560c2d6ac756  clang::RecursiveASTVisitor<>::TraverseFunctionDecl()
    @     0x560c2d6a713c  clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl()
    @     0x560c2d66b78b  clang::ast_matchers::MatchFinder::matchAST()
    @     0x560c2c3bdffe  clang::clangd::ParsedAST::build()
    @     0x560c2c3c0001  clang::clangd::buildAST()

The check calls ASTContext::getTypeInfo(), the ASTContext::getTypeInfo() has a side effect which may produce a new diagnostic and we are current running the check when processing another diagnostic, which triggers this assertion. (the issue only occurs in clangd, not clang-tidy).

It looks like there is no trivial fix for it, we need more investigations.

@hokein hokein added the bug Something isn't working label Sep 17, 2019
Ktwu pushed a commit to Ktwu/llvm-project that referenced this issue Apr 24, 2020
Summary:
this maybe not ideal, but it is trivial and does fix the crash.

Fixes clangd/clangd#156.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78715

upstream-commit: a466e4b
hokein added a commit to llvm/llvm-project that referenced this issue Jun 10, 2020
Summary:
this maybe not ideal, but it is trivial and does fix the crash.

Fixes clangd/clangd#156.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78715

(cherry picked from commit a466e4b)
arichardson pushed a commit to arichardson/llvm-project that referenced this issue Jul 2, 2020
Summary:
this maybe not ideal, but it is trivial and does fix the crash.

Fixes clangd/clangd#156.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78715
ajohnson-uoregon pushed a commit to ajohnson-uoregon/clang-rewrite-only that referenced this issue Jul 17, 2022
Summary:
this maybe not ideal, but it is trivial and does fix the crash.

Fixes clangd/clangd#156.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78715

(cherry picked from commit 5dd101b)
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
Summary:
this maybe not ideal, but it is trivial and does fix the crash.

Fixes clangd/clangd#156.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78715
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant