[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-12-20 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment. Thanks for the reviews! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70470/new/ https://reviews.llvm.org/D70470 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-12-20 Thread Gábor Horváth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. xazax.hun marked 2 inline comments as done. Closed by commit rG82923c71efa5: [analyzer] Add Fuchsia Handle checker (authored by xazax.hun). Changed prior to commit: https://reviews.llvm.org/D70470?vs=233691&id=234948#toc

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-12-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. LGTM! Yeah, please update the ASCII-art, it's great and every checker should have it. Comment at: clang/docs/analyzer/checkers.rst:1341 + +Fuchsia Checkers. + May

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-12-12 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 233691. xazax.hun added a comment. - Fix some problems discovered during some real world stress test - Add more tests - The ASCII art is not updated yet, but will do so at some point. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70470/new/ https:

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-12-02 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. > I feel like the 2. is a better solution. Of course, that change might have a > performance impact as well. Yes, i'm all for '2.'. There's no need to make this callback more complicated than it already is. As for performance, it's messy and suffers from a deeper problem:

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-11-26 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment. Ok, now I have some real world experience with the results of the check. The false positive ratio for double free and use after free seems to be quite good but the handle leak part is almost unusable at this point. The main problem is somewhat anticipated, we are not d

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-11-26 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 231089. xazax.hun added a comment. - Handle cases where the number of args/params mismatch. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70470/new/ https://reviews.llvm.org/D70470 Files: clang/docs/analyzer/checkers.rst clang/include/clang/S

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-11-25 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked an inline comment as done. xazax.hun added inline comments. Comment at: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp:336-338 +ProgramStateRef FuchsiaHandleChecker::evalAssume(ProgramStateRef State, + S

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-11-22 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 230668. xazax.hun added a comment. - Fix member operator modeling. - Added new lines to the end of files. - Added documentation. - Minor typo fixes in tests. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70470/new/ https://reviews.llvm.org/D70470

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-11-21 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 230500. xazax.hun edited the summary of this revision. xazax.hun added a comment. - Make the patch standalone and the check on by default for the fuchsia platform. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70470/new/ https://reviews.llvm.org/

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-11-21 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked an inline comment as done. xazax.hun added inline comments. Comment at: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp:19-20 +// handle variable is passed to different function calls or syscalls, its state +// changes. The state changes can be general

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-11-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp:19-20 +// handle variable is passed to different function calls or syscalls, its state +// changes. The state changes can be generally represented by following ASCII +// Art: +// ---

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-11-20 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 230287. xazax.hun marked 10 inline comments as done. xazax.hun added a comment. - Explicitly model "maybe" states. - Fix some escaping issues. - Address most review comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70470/new/ https://reviews

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-11-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp:207 + int PtrToHandleLevel = 0; + const Type *T = QT.getTypePtr(); + while (T->isAnyPointerType() || T->isReferenceType() || T->isArrayType()) { xazax.hun wrote:

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-11-19 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 230187. xazax.hun added a comment. - Addressed **some** of the review comments. More changes are planned :) CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70470/new/ https://reviews.llvm.org/D70470 Files: clang/include/clang/StaticAnalyzer/Check

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-11-19 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked 13 inline comments as done. xazax.hun added a comment. Thanks for the review! I am not very well versed in Fuchsia's syscalls yet but my understanding is that not all of the syscalls can fail so we do not need all the users to check for errors. But this is something I will veri

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-11-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. Yay, i see the "Schrödinger handle" pattern: until the return value of release is checked, the handle is believed to be both dead and alive at the same time. We usually use this pattern because a lot of code that's already written doesn't check their return values. But do y

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-11-19 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked an inline comment as done. xazax.hun added inline comments. Comment at: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp:67 +// functions: +// 1. __attribute__((clang::acquire_handle)) |handle will be acquired +// 2. __attribute__((clang::release_hand

[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

2019-11-19 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun created this revision. xazax.hun added reviewers: NoQ, haowei. xazax.hun added a project: clang. Herald added subscribers: Charusso, gamesh411, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, whisperity, mgorny. This check is based on ht