This is an archive of the discontinued LLVM Phabricator instance.

[Analyzer] Iterator Checkers - Make range errors and invalidated access fatal
ClosedPublic

Authored by baloghadamsoftware on Jun 5 2019, 2:14 AM.

Details

Summary

Range errors (dereferencing or incrementing the past-the-end iterator or decrementing the iterator of the first element of the range) and access of invalidated iterators lead to undefined behavior. There is no point to continue the analysis after such an error on the same execution path, but terminate it by a sink node (fatal error). This also improves the performance and helps avoiding double reports (e.g. in case of nested iterators).

Diff Detail

Repository
rL LLVM

Event Timeline

I left errors caused by mismatched iterators non-fatal for now. This is debatable because passing a function expecting a range iterators for two different containers or applying a container modifier using a mismatched iterator also leads to undefined behavior. However, comparing two iterators of different containers always returns false thus it is non-fatal. Maybe we should separate these two cases and report the first one as fatal, the second one as non-fatal errors.

Szelethus accepted this revision.Jul 31 2019, 1:54 AM

Makes sense! But, does any of the test cases actually test *this* particular change?

This revision is now accepted and ready to land.Jul 31 2019, 1:54 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 29 2019, 2:34 AM

Makes sense! But, does any of the test cases actually test *this* particular change?

I added some reachability checks before committing.