Skip to content

Commit b7ab0f7

Browse files
author
Vince Bridgers
committed
[analyzer] Remove assert from CheckerManager for registered Events
Random testing revealed it's possible to crash the analyzer through a rare command line invocation: clang -cc1 -analyze -analyzer-checker=nullability empty.c The assert in CheckerManager.cpp was deemed to be too strict so is removed. clang: <root>/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp:56: void clang::ento::CheckerManager::finishedCheckerRegistration(): Assertion `Event.second.HasDispatcher && "No dispatcher registered for an event"' failed. PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ Stack dump: 0. Program arguments: clang -cc1 -analyze -analyzer-checker=nullability nullability-nocrash.c #0 ... ... #7 <addr> clang::ento::CheckerManager::finishedCheckerRegistration() #8 <addr> clang::ento::CheckerManager::CheckerManager(clang::ASTContext&, clang::AnalyzerOptions&, clang::Preprocessor const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, llvm::ArrayRef<std::function<void (clang::ento::CheckerRegistry&)>>)
1 parent 1a12647 commit b7ab0f7

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

clang/lib/StaticAnalyzer/Core/CheckerManager.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,7 @@ bool CheckerManager::hasPathSensitiveCheckers() const {
4848
EvalCallCheckers, EndOfTranslationUnitCheckers);
4949
}
5050

51-
void CheckerManager::finishedCheckerRegistration() {
52-
#ifndef NDEBUG
53-
// Make sure that for every event that has listeners, there is at least
54-
// one dispatcher registered for it.
55-
for (const auto &Event : Events)
56-
assert(Event.second.HasDispatcher &&
57-
"No dispatcher registered for an event");
58-
#endif
59-
}
51+
void CheckerManager::finishedCheckerRegistration() {}
6052

6153
void CheckerManager::reportInvalidCheckerOptionValue(
6254
const CheckerBase *C, StringRef OptionName,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %clang_analyze_cc1 -w -analyzer-checker=nullability \
2+
// RUN: -analyzer-output=text -verify %s
3+
//
4+
// expected-no-diagnostics
5+
//
6+
// This case previously crashed because of an assert in CheckerManager.cpp,
7+
// checking for registered event dispatchers. This check is too strict so
8+
// was removed by this commit. This test case covers the previous crash,
9+
// and is expected to simply not crash. The source file can be anything,
10+
// and does not need to be empty.

0 commit comments

Comments
 (0)