Hi Thomas,

In NVDA, we sometimes see access violation and vtable errors in __del__ 
on comtypes COM POINTER objects and intermittant crashes. I eventually 
figured that this might relate to Release() being called too many times. 
I then discovered that __del__ on these objects is sometimes called more 
than once. (We never call __del__ ourselves, so this is happening 
elsewhere.) As I understand it, Python should only ever call it once.

I discovered this using the following rather nasty monkey patch before 
any COM objects are used:

from comtypes import _compointer_base
_cpbDel = _compointer_base.__del__
def newCpbDel(self):
        assert not hasattr(self, "_deleted"), "compointer already deleted"
        _cpbDel(self)
        self._deleted = True
newCpbDel.__name__ = "__del__"
_compointer_base.__del__ = newCpbDel
del _compointer_base

This assertion does get raised. While I have come up with an exact set 
of steps to reproduce with NVDA and Firefox, I haven't yet managed to 
narrow it down to a programmatic test case due to the sheer number of 
interactions and code paths. I can tell you that we use QueryInterface 
quite a bit if that helps in any way.

Can you think of any reason this might be happening? Is there any code 
in the ctypes POINTER type that calls __del__?

Thanks.

Jamie

-- 
James Teh
Email/MSN Messenger/Jabber: ja...@jantrid.net
Web site: http://www.jantrid.net/


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users

Reply via email to