Skip to content

Commit 7e37383

Browse files
author
Vince Bridgers
committed
[analyzer] Prevent crash due to missing EventDispatch in corner case
Random testing revealed it's possible to crash the analyzer through a rare command line invocation: clang -cc1 -analyze -analyzer-checker=nullability empty.c where the source file, empty.c is an empty source file. This change simply registers the ImplictNullDeref Event Dispatcher as is done in other similar checks to avoid the crash. 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 9a2fd97 commit 7e37383

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class NullabilityChecker
8484
check::PostCall, check::PostStmt<ExplicitCastExpr>,
8585
check::PostObjCMessage, check::DeadSymbols, eval::Assume,
8686
check::Location, check::Event<ImplicitNullDerefEvent>,
87+
/*EventDispatcher<ImplicitNullDerefEvent>,*/
8788
check::BeginFunction> {
8889

8990
public:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: %clang_analyze_cc1 -w -analyzer-checker=nullability \
2+
// RUN: -analyzer-output=text -verify %s
3+
//
4+
// expected-no-diagnostics

0 commit comments

Comments
 (0)