This is an archive of the discontinued LLVM Phabricator instance.

[clang][analyzer] Display notes in StdLibraryFunctionsChecker only if interesting
ClosedPublic

Authored by balazske on Jun 26 2023, 8:11 AM.

Details

Summary

The note tag that was previously added in all cases when a standard function call
is found is displayed now only if the function call (return value) is "interesting".
This results in less unneeded notes but some of the previously good notes disappear
too. This is because interestingness is not always set as it should be.

Diff Detail

Event Timeline

balazske created this revision.Jun 26 2023, 8:11 AM
Herald added a reviewer: NoQ. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
balazske requested review of this revision.Jun 26 2023, 8:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 26 2023, 8:11 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
steakhal added inline comments.Jun 26 2023, 8:48 AM
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
1336

Why do you continue here? Do you have a case for this?

balazske updated this revision to Diff 534868.Jun 27 2023, 1:24 AM

markInteresting must be used at arguments found to be invalid

Here are results for vim, still the fileno problem is not fixed. This run was made before the last update where markInteresting is added, then it should work.

balazske added inline comments.Jun 27 2023, 1:39 AM
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
1336

This is only because the same loop has other failure places (if the state can not be applied) where continue is used already. The reason is that if one addTransition fails a next one may succeed. It is probably better to use break at all places. Even then what was already added to the state can not be removed, so it may be not wrong to add all states that can be added.

donat.nagy accepted this revision.Jun 29 2023, 8:14 AM

LGTM if you rebase these changes onto the most recent version of D153612. Thanks for adding this interestingness check!

This revision is now accepted and ready to land.Jun 29 2023, 8:14 AM
balazske updated this revision to Diff 536133.Jun 30 2023, 12:37 AM

Rebase to newest parent review version.

results with the latest version:
memcached_1.6.8_stdclf_notetag_interesting_test_2Reports
tmux_2.6_stdclf_notetag_interesting_test_2Reports
curl_curl-7_66_0_stdclf_notetag_interesting_test_2Reports
twin_v0.8.1_stdclf_notetag_interesting_test_2Reports
vim_v8.2.1920_stdclf_notetag_interesting_test_2Reports
openssl_openssl-3.0.0-alpha7_stdclf_notetag_interesting_test_2Reports
sqlite_version-3.33.0_stdclf_notetag_interesting_test_2Reports
ffmpeg_n4.3.1_stdclf_notetag_interesting_test_2Reports
postgres_REL_13_0_stdclf_notetag_interesting_test_2Reports
xerces_v3.2.3_stdclf_notetag_interesting_test_2Reports
bitcoin_v0.20.1_stdclf_notetag_interesting_test_2Reports
donat.nagy requested changes to this revision.Jun 30 2023, 8:43 AM

Thanks for attaching the test results! Unfortunately it seems that it was important to look at them, because I noticed that in the posgresql codebase there are many bug reports on calls like func1(func2(...), ...) where the checker does not print the expected "Assuming that 'func2' fails" note: fdopen/dup, fstat/fileno, isatty/fileno, another isatty/fileno, a third isatty/fileno, a second dup/fileno (this is not an exhaustive list, but I think I listed the majority of them).

Please investigate these before merging your commits.

This revision now requires changes to proceed.Jun 30 2023, 8:43 AM

The success/failure note tags are not added to all functions, dup is one of these, this means at dup no note tag is shown. A next patch can be made to add these messages to all functions. The other places look good, but CodeChecker is a bit tricky, you must select *_stdclf_notetag_interesting_test_2 at the small arrow after the "found in:" text (upper right corner). The link is good but not that instance of the bug is displayed because only the note tags are different.

The success/failure note tags are not added to all functions, dup is one of these, this means at dup no note tag is shown. A next patch can be made to add these messages to all functions. The other places look good, but CodeChecker is a bit tricky, you must select *_stdclf_notetag_interesting_test_2 at the small arrow after the "found in:" text (upper right corner). The link is good but not that instance of the bug is displayed because only the note tags are different.

I think we should definitely add success/failure note tags to all functions where this checker can suddenly assume that "Oops, this failed". If this "Assuming that 'foo' fails" message is not there, it's a very natural reaction to search for some earlier note that would let the checker deduce that this function will fail here.

donat.nagy accepted this revision.Jul 10 2023, 2:11 AM

LGTM, thanks!

This revision is now accepted and ready to land.Jul 10 2023, 2:11 AM
This revision was landed with ongoing or failed builds.Jul 18 2023, 12:29 AM
This revision was automatically updated to reflect the committed changes.