classification
Title: Run clang's static analyzer
Type: Stage: resolved
Components: Extension Modules, Interpreter Core Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, jcea, petri.lehtinen, pitrou, rhettinger
Priority: low Keywords: patch

Created on 2010-06-06 03:32 by brett.cannon, last changed 2011-07-27 21:49 by brett.cannon. This issue is now closed.

Files
File name Uploaded Description Edit
clang_analyzer_253.tar.xz brett.cannon, 2011-01-27 17:49 tar.xz file of the HTML output
clang_analyzer.diff brett.cannon, 2011-02-03 20:34 Remove worthless assignments and increments
analyzer_fixes.diff brett.cannon, 2011-02-04 00:11 Fixes various issues along with using the noreturn attribute
checker_254_2011-02-03.tar.xz brett.cannon, 2011-02-04 00:12 Clang static analyzer v254 results w/ analyzer_fixes.diff applied
wheres_my_pony.diff brett.cannon, 2011-02-04 01:23 Patch with everything
Messages (16)
msg107180 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2010-06-06 03:32
Just like I did for Python 2.7.

Should use this issue to keep track of what I have already processed and what I had to skip because OS X doesn't have the right files.
msg127167 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2011-01-27 02:31
Analyzed by downloading the latest Clang static analyzer from http://clang-analyzer.llvm.org/ and running ``scan-build ./configure --with-pydebug; scan-build make -s -j2``. The attached tar.xz (yes I went with a cutting edge archival format; get pax on UNIX to read it) contains the HTML report.
msg127169 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2011-01-27 02:50
Well, there is no upload because the compressed file is 70 MB. But you can download the file from https://docs.google.com/leaf?id=0B7CvitGf6YffMGFlYTg2N2UtMjY3Yi00ZTg1LWI2NWUtNmRiMmEwYzZjMTQ1&sort=name&layout=list&num=50 .
msg127203 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2011-01-27 17:49
Turns out I was using pax wrong. =) Thought it automatically compressed new files; turns out it doesn't. Using the zx compressor it shrank the 70 MB file down, so ignore the Google Docs upload and just grab this.
msg127205 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-01-27 17:54
For the record, you don't have to use pax, recent GNU tar handles xz fine (use the -J option).
msg127781 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2011-02-03 02:27
Here is a patch that covers all of the relevant dead assignments that were detected.
msg127785 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2011-02-03 07:26
Nice work. I'm surprised there wasn't more dead code.
msg127807 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2011-02-03 19:28
This was just dead assignments. I have not tackled Idempotent operations, dead increments, dead initializations, dead nested assignments, possible deref of NULL, deref of unassigned pointer, division by zero, undefined/garbage results, or undefined alloc of 0 bytes.

IOW I tackled 36 out of 164 reported issues. =)
msg127819 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2011-02-03 20:34
Am looking forward to the rest.
This will be a nice cleanup.
msg127820 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2011-02-03 20:34
New patch which covers dead assignments and increments.
msg127834 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2011-02-04 00:11
Here is a new patch which includes setting the noreturn attribute on Py_FatalError() and Py_Exit() in order to make the null pointer deref analysis results more tractable.
msg127835 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2011-02-04 00:12
This is a new set of results with the analyzer_fixes.diff file applied using the latest analyzer.
msg127852 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2011-02-04 01:23
OK, done going through the results. Attached is a patch with all of the fixes (only one actual bug which I file an issue for separately; everything else is removing a little bit of dead code here and there).
msg129119 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2011-02-22 20:19
applied in r88506
msg141259 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2011-07-27 18:35
Regarding issue 12595 (function redeclaration warning when including Python.h), could a small part (or optionally all) of this patch be backported to 3.2?
msg141278 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2011-07-27 21:49
I don't feel comfortable changing what is defined in a header file in a point release, so I am not going to backport the fix.
History
Date User Action Args
2011-07-27 21:49:45brett.cannonsetmessages: + msg141278
2011-07-27 18:35:09petri.lehtinensetnosy: + petri.lehtinen
messages: + msg141259
2011-07-27 11:19:24petri.lehtinenunlinkissue12595 superseder
2011-07-27 11:17:55petri.lehtinenlinkissue12595 superseder
2011-02-22 20:19:30brett.cannonsetstatus: open -> closed
nosy: brett.cannon, rhettinger, jcea, pitrou
messages: + msg129119

resolution: fixed
stage: resolved
2011-02-04 01:23:32brett.cannonsetfiles: + wheres_my_pony.diff
nosy: brett.cannon, rhettinger, jcea, pitrou
messages: + msg127852
2011-02-04 00:12:52brett.cannonsetfiles: + checker_254_2011-02-03.tar.xz
nosy: brett.cannon, rhettinger, jcea, pitrou
messages: + msg127835
2011-02-04 00:11:07brett.cannonsetfiles: + analyzer_fixes.diff
nosy: brett.cannon, rhettinger, jcea, pitrou
messages: + msg127834
2011-02-03 20:34:51brett.cannonsetfiles: + clang_analyzer.diff
nosy: brett.cannon, rhettinger, jcea, pitrou
messages: + msg127820
2011-02-03 20:34:18brett.cannonsetfiles: - clang_analyzer.diff
nosy: brett.cannon, rhettinger, jcea, pitrou
2011-02-03 20:34:07rhettingersetnosy: brett.cannon, rhettinger, jcea, pitrou
messages: + msg127819
2011-02-03 19:28:07brett.cannonsetnosy: brett.cannon, rhettinger, jcea, pitrou
messages: + msg127807
2011-02-03 07:26:49rhettingersetnosy: + rhettinger
messages: + msg127785
2011-02-03 02:27:29brett.cannonsetfiles: + clang_analyzer.diff

messages: + msg127781
keywords: + patch
nosy: brett.cannon, jcea, pitrou
2011-01-27 17:54:27pitrousetnosy: + pitrou
messages: + msg127205
2011-01-27 17:49:56brett.cannonsetfiles: + clang_analyzer_253.tar.xz
nosy: brett.cannon, jcea
messages: + msg127203
2011-01-27 02:50:08brett.cannonsetnosy: brett.cannon, jcea
messages: + msg127169
2011-01-27 02:31:40brett.cannonsetnosy: brett.cannon, jcea
messages: + msg127167
2010-11-23 03:51:44jceasetnosy: + jcea
2010-06-06 03:32:53brett.cannoncreate