Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#6 Memory allocation/deallocation mismatch causes segfault

open
nobody
None
5
2007-04-18
2007-04-18
WaffleSouffle
No

This is based on running run_tests with both release and debug builds of kjbuckets. Haven't looked at code beyond tracking down what I think is the problem so, for example, have no idea what an Sgroup is.

Essentially kjbucketsmodule.c allocates "groups.Sgroups" with "calloc()" on lines 823-824

However it is deallocated on line 930 in "groupsDealloc()" using "PyMem_Del()" (which does some guard-byte checks in debug builds) and barfs.
The easy fix that I have built and checked with run_tests is to replace this line (930) in kjbucketsmodule.c
- PyMem_Del(g.Sgroups);
with this line
+ free(g.Sgroups);

This seems to build and run ok in my limited tests, but that really is limited

Discussion

  • WaffleSouffle
    WaffleSouffle
    2007-04-18

    Patched kjbucketsmodule.c file

     
    Attachments
  • WaffleSouffle
    WaffleSouffle
    2007-04-18

    Logged In: YES
    user_id=1772649
    Originator: YES

    Should have said, tested on Windows 2000 SP3 using MSVS2003 and VS6.0, with Python 2.3.6