5 ms·
Having done similar work for Chrome, I can attest to the fact that large code bases are full of errors. If you're not on Windows, using both gcc's -Wall and -W
by evmar 15y ago
Having done similar work for Chrome, I can attest to the fact that large code bases are full of errors.
If you're not on Windows, using both gcc's -Wall and -Wextra along with Clang in the same way is a good start. (Here's a post with more details: http://neugierig.org/software/chromium/notes/2011/01/clang.html http://neugierig.org/software/chromium/notes/2011/01/clang.h... .) The Clang static analyzer wasn't very useful at the time I tried it because it didn't analyze C++ code. Valgrind also finds a lot but it is harder to be diligent about fixing.
The PVS Studio guy (mentioned in Carmack's post) ran our code through it as well and also found a number of bugs, as described in a few posts: http://www.viva64.com/en/a/0074/ http://www.viva64.com/en/a/0074/ http://www.viva64.com/en/b/0113/ http://www.viva64.com/en/b/0113/ . (As Carmack supposed, they also claimed the Chrome code was some of the best they'd seen. But it's more likely they were being truthful in both cases.)
They've also ran the Chrome code through Coverity, but I haven't been involved in fixing those bugs so I don't know how useful it was. Searching the bug tracker for [coverity] turns up a handful of bugs, but it's possible more are hidden for security reasons.
- masklinn 15y ago> As Carmack supposed, they also claimed the Chrome code was some of the best they'd seen. But it's more likely they were being truthful in both cases Carmack said that for Coverity though, not for PVS.
- AndreyKarpov 15y agoPVS-Studio vs Chromium - http://www.viva64.com/en/a/0074/ http://www.viva64.com/en/a/0074/ PVS-Studio vs Chromium - Continuation - http://www.viva64.com/en/b/0113/ http://www.viva64.com/en/b/0113/
- 16s 15y agoYou may also consider using -Weffc++ in addition to -Wall and -Wextra if you are using g++.
- groby_b 15y agoAdditional data point: Coverity is indeed quite useful. I'd say at least once a week it turns up something that could turn into a critical issue if left unfixed. So yes, static analysis really does matter. The problem with static analysis is programmer hybris - "No, don't initialize that variable. I've envisioned every execution path, and it's impossible to ever be used uninitialized. And not initializing it is so much more efficient!". Cue crash reports due to uninitialized variables about 4 weeks later.... [Side note:Since Coverity bugs are rarely filed in the bug tracker, it'd be more effective to search CL's for the string CID= which identifies Coverity bug reports. And no, security-critical fixes won't get that marker ;)] As for PVS, I'm itching to see a full report on Chrome. The excerpts he post are very interesting, and have a good amount of bugs that are not flagged by Coverity. (I assume vice versa applies, hence the wish to look at a full report). Now I just need to make some time to run an eval...