This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Prevent crashes in FindLastStoreBRVisitor
ClosedPublic

Authored by george.karpenkov on Sep 24 2018, 2:05 PM.

Details

Summary

This patch is a band-aid. A proper solution would be too change trackNullOrUndefValue to only try to dereference the pointer when it is relevant to the problem.

Diff Detail

Repository
rL LLVM

Event Timeline

NoQ accepted this revision.Sep 24 2018, 2:14 PM
NoQ added inline comments.
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
1742 ↗(On Diff #166749)

I almost want to make Optional<Loc> non-convertible to bool, because it's almost always a bad idea to make decisions based on Loc-ness of SVal, as a lot of code assumes that Loc means lvalue, which is completely incorrect.

This revision is now accepted and ready to land.Sep 24 2018, 2:14 PM
Szelethus added inline comments.Sep 24 2018, 2:17 PM
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
1758 ↗(On Diff #166749)

I think ShouldFindLastStore would be more descriptive.

1760 ↗(On Diff #166749)

Does this also work for void **?

clang/test/Analysis/diagnostics/find_last_store.c
1 ↗(On Diff #166749)

Space after //

george.karpenkov marked 2 inline comments as done.Sep 24 2018, 2:19 PM
george.karpenkov added inline comments.
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
1760 ↗(On Diff #166749)

The problem is FindLastStoreBRVisitor will later crash without this branch when attempting to dereference the region.
This problem will not occur with void** because it's OK to dereference that.

This revision was automatically updated to reflect the committed changes.
Szelethus added inline comments.Sep 24 2018, 2:25 PM
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
1760 ↗(On Diff #166749)

Oh right, thanks!