llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Run scan-build twice then NO bugs found

Open xiangzhai opened this issue 9 years ago • 5 comments

Bugzilla Link 31442
Resolution INVALID
Resolved on Dec 22, 2016 21:05
Version 3.9
OS Linux
CC @devincoughlin

Extended Description

Hi Clang developers,

For example, I use scan-build to static analysis K3B https://github.com/KDE/k3b

cmake .. Run scan-build -k -v -V make -j 5

There are 10 bugs found, but run scan-build again, then there is NO bugs found!

Regards, Leslie Zhai

xiangzhai avatar Dec 21 '16 04:12 xiangzhai

For example, Clang Static Analyzer detected out-of-bounds issue https://pbs.twimg.com/media/C0VGgJwUsAAFSPN.jpg

then I changed the source file, scan-build again, and I added fuzzer testcase for the https://github.com/KDE/k3b/commit/14b4eca536e001b6eeecadabc8876f8d7169551e

One thing you can do is pass '-v -v -v' to scan-build to check to make sure 'make' is rebuilding the files you expect.

It works for me, thanks for your advice ;-)

xiangzhai avatar Dec 23 '16 05:12 xiangzhai

Did you do a 'make clean' between the two runs of scan-build? Makefile is able to detect changes in source files, so I argue that scan-build might be able to analyze the changed files, it might be a strange requirement ;-) but thanks again for your reply!

It is supposed to work they way you describe (only reanalyze files recompiled on a rebuild). One thing you can do is pass '-v -v -v' to scan-build to check to make sure 'make' is rebuilding the files you expect.

devincoughlin avatar Dec 22 '16 18:12 devincoughlin

Did you do a 'make clean' between the two runs of scan-build?

no. because, for example k3b http://github.com/KDE/k3b about 99,482 lines source code, when I fixed some bugs detected by Clang Static Analyzer, I want to scan-build -k -v -v -V make -j4 directly. so if make clean, then scan-build, I need some coffee to kill time ;-)

because the project was already already built the first time!) then there will be > no compiled files for scan-build to analyze.

Makefile is able to detect changes in source files, so I argue that scan-build might be able to analyze the changed files, it might be a strange requirement ;-) but thanks again for your reply!

Regards, Leslie Zhai - http://clang-analyzer.llvm.org.cn

xiangzhai avatar Dec 22 '16 17:12 xiangzhai

Leslie,

Did you do a 'make clean' between the two runs of scan-build?

scan-build interposes the build system to analyze files as they are compiled. This means that if you run scan-build make ... twice and the second invocation doesn't compile anything (because the project was already already built the first time!) then there will be no compiled files for scan-build to analyze.

devincoughlin avatar Dec 21 '16 18:12 devincoughlin

assigned to @tkremenek

xiangzhai avatar Dec 21 '16 04:12 xiangzhai