[PyKDE] Double free() problem in PyQt 3.15.1??

Jim Bublitz jbublitz at nwinternet.com
Sat Mar 11 20:41:46 GMT 2006


On Saturday 11 March 2006 11:13, Simon Edwards wrote:
> Hi Phil and everybody else,
>
> I'm busy working on polishing and debugging stuff for the coming Kubuntu
> release, which makes increasingly more use of PyQt+PyKDE BTW.
>
> Anyway, I think I've come across a double free memory bug in PyQt 3.15.1.
> Qt complains about a "Double QObject deletion detected.", and valgrind
> points to a problem in sipKDialogBase::~sipKDialogBase(). (Reading memory
> which is already free'd, and invalid free(), delete etc). This problem only
> appears when my app opens a dialog.
>
> This problem does not occur with PyQt 3.14.1. Comparing the two PyQt
> releases I see this added to the 3.15.1 qdialog.sip:
>
> -----------------------------
> %If (- Qt_3_0_0)
> 	int exec() /PyName=exec_loop, ReleaseGIL,
> 		    PreHook=__pyQtPreEventLoopHook__,
> 		    PostHook=__pyQtPostEventLoopHook__/;
> %MethodCode
> 		// Transfer ownership back to Python (a modal dialog will
> 		// probably have the main window as it's parent).  This means
> 		// the Qt dialog will be deleted when the Python wrapper is
> 		// garbage collected.  Although this is a little inconsistent,
> 		// it saves having to code it explicitly to avoid the memory
> 		// leak.
> 		sipTransferBack(sipSelf);
>
> 		Py_BEGIN_ALLOW_THREADS
> 		sipRes = sipCpp->QDialog::exec();
> 		Py_END_ALLOW_THREADS
> %End
> %End
> -----------------------------
>
> This does look like it could be the problem. Phil?

That code is only compiled for Qt < 3.0.0; the code for Qt >= 3.0.0 is a 
little farther down in the sip file:

%If (Qt_3_0_0 -)
	int exec() /PyName=exec_loop, ReleaseGIL,
		    PreHook=__pyQtPreEventLoopHook__,
		    PostHook=__pyQtPostEventLoopHook__/;
%End

PyKDE/examples/uisampler.py has a KDailogBase example. It uses show() instead 
of exec_loop() as shipped, but it works using exec_loop() as well with recent 
sip/PyQt snapshots (newer than 3.15). I don't have a 3.15.x version running I 
can test it with.

However there are a lot of variables in what child widgets KDialogBase 
actually constructs, and the problem might be with one of those, so a 
specific example would be helpful.

Jim





More information about the PyQt mailing list