[PyQt] Destructor being called on a subthread.

Phil Thompson phil at riverbankcomputing.com
Thu Jul 31 15:54:05 BST 2008


On Thu, 31 Jul 2008 14:42:17 +0000 (UTC), Kevin Watters
<kevinwatters at gmail.com> wrote:
> I've got a sporadic crash in my app (not PyQT) and I think I have it
> narrowed down.
> 
> 1) Main thread creates a Flub object. 
> 2) Main thread releases all references to the Flub object, but there's a
> cycle,
> so the object isn't collected immediately.
> 3) Worker thread does some unrelated work, during which a garbage
> collection happens.
> 4) This collection on the worker thread results in a deallocation for
> the Flub object created in (1).
> 5) The Flub object's destructor cleans up structures which are not
> thread safe, and an access violation occurs (sometimes).
> 
> What can I do about this?  I'm thinking about making SIP thunk all
> deallocations for Flub objects back to the main thread, but I wanted to
> see if PyQT has or has confronted this problem before...

You could look at the call to PyObject_GC_UnTrack() in
sipWrapper_dealloc(). I don't think it's the same problem, but there may be
similarities.

Phil



More information about the PyQt mailing list