Bug 800075

Summary: Memory leaks and possible crashers found in newt-0.52.14-2.fc17 using gcc-with-cpychecker static analyzer
Product: [Fedora] Fedora Reporter: Dave Malcolm <dmalcolm>
Component: newtAssignee: Miroslav Lichvar <mlichvar>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: mlichvar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
URL: http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/newt-0.52.14-2.fc17/
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-03-21 14:38:30 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 789472    

Description Dave Malcolm 2012-03-05 12:19:21 EST
Description of problem:
I've been writing an experimental static analysis tool to detect bugs commonly occurring within C Python extension modules:

I ran the latest version of the tool (in git master; post 0.9) on
newt-0.52.14-2.fc17.src.rpm, and it reports various errors.

You can see a list of errors here, triaged into categories (from most significant to least significant):

I've manually reviewed the issues reported by the tool.

Within the category "Reference leaks" the 6 issues reported appear to be genuine memory leaks (although the line numbering seems to be slightly incorrect):  within snackmodule.c:widgetListboxGetSel, "sel" gets allocated twice: with a non-empty selection, every call will leak the first list allocated (at line 1097).  Also the reference to the PyIntObject allocated at PyInt_FromLong((long) selection[i])) will be leaked (since PyList_Append adds a new reference, rather than stealing the one passed in ); if the int is > 256 then this will be a memory leak since a new PyIntObject will be allocated.

The bugs in widgetCheckboxTreeGetSel appear to be analogous to those in widgetListboxGetSel.

Within the category "Reference leak within initialization" the 2 issues reported are inconsequential (this code is called only once, at import).

Within the category "Segfaults within error-handling paths" the 10 issues reported look like genuine bugs, in that crashes could occur here under low-memory conditions (i.e. where an allocation fails, and the indicated call returns a NULL).

Within the category "Returning (PyObject*)NULL without setting an exception" the 1 issue reported may or may not be a genuine bug  (if it is, it's a minor one), depending on whether newtCheckboxTreeGetEntryValue sets an exception when it returns -1.

There may of course be other bugs in my checker tool.

Hope this is helpful; let me know if you need help reading the logs that the tool generates - I know that it could use some improvement.

Version-Release number of selected component (if applicable):
gcc-python-plugin post-0.9 git 11462291a66c8db693c8884cb84b795bb5988ffb running the checker in an *f16* chroot
Comment 1 Miroslav Lichvar 2013-03-21 14:38:30 EDT
All reported problems should be fixed by:

Thanks for the report, it's a very nice tool!