GNOME Bugzilla – Bug 549945
pygobject has memory problems
Last modified: 2008-08-30 19:05:42 UTC
On my system (python 2.4.5 configure with --with-pydebug --without-pymalloc), running "python -c 'import gobject'" will cause libc to complain about double free corruption. Running with valgrind also shows memory errors.
Created attachment 117642 [details] valgrind log
Do you have 64-bit machine?
Of course ;-)
I guess it is architecture-dependent. I didn't bother to recompile Python, but ran valgrind on importing in Python 2.5 and Python 2.3 and got none such errors. Looking at the source code --- structure PyGPropsDescr_Type and similar is defined with PYGLIB_DEFINE_TYPE(). That macro initializes only a few first fields, leaving out the rest. I don't remember if C compiler is obliged to initialize static structures with zeros or not (though here it seems like it does). Can the errors be caused by uninitialized fields?
I think you should end the structure with ...,0,}; to force zero initialization. Anyway, I added it and it makes no difference. But I found the real problem: sizeof(0) == 4, not 0. Fixed now.