Skip to content

Commit

Permalink
[analyzer] Avoid a crash in a debug printout function (#79446)
Browse files Browse the repository at this point in the history
Previously the function `RangeConstraintManager::printValue()` crashed
when it encountered an empty rangeset (because `RangeSet::getBitwidth()`
and `RangeSet::isUnsigned()` assert that the rangeset is not empty).
This commit adds a special case that avoids this behavior.

As `printValue()` is only used by the checker debug.ExprInspection (and
during manual debugging), the impacts of this commit are very limited.

---------

Co-authored-by: Balazs Benics <benicsbalazs@gmail.com>
  • Loading branch information
NagyDonat and steakhal committed Jan 25, 2024
1 parent f1b1611 commit 9b71393
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3270,6 +3270,10 @@ void RangeConstraintManager::printJson(raw_ostream &Out, ProgramStateRef State,
void RangeConstraintManager::printValue(raw_ostream &Out, ProgramStateRef State,
SymbolRef Sym) {
const RangeSet RS = getRange(State, Sym);
if (RS.isEmpty()) {
Out << "<empty rangeset>";
return;
}
Out << RS.getBitWidth() << (RS.isUnsigned() ? "u:" : "s:");
RS.dump(Out);
}
Expand Down

1 comment on commit 9b71393

@NagyDonat
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got an automatic email about a buildbot failure that's supposedly connected to this commit: https://lab.llvm.org/buildbot/#/builders/269/builds/4342

It complains about unexpected symbols

+ diff -u /b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/lib/sanitizer_common/symbolizer/scripts/global_symbols.txt undefined.new
+__start___lcxx_override U
+__stop___lcxx_override U
+ echo 'Failed: unexpected symbols'

and missing <csstddef> in some googletest files

In file included from /b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/lib/fuzzer/tests/FuzzedDataProviderUnittest.cpp:5:/b/sanitizer-aarch64-linux/build/llvm-project/runtimes/../third-party/unittest/googletest/include/gtest/gtest.h:52:10: fatal error: 'cstddef' file not found

but I'm fairly sure that these issues are both completely unrelated to my change (and I'm not competent to investigate them in detail, because I'm not familiar with the systems that produced them).

Please sign in to comment.