[Python-Dev] tp_dealloc

smarv at gmx.net smarv at gmx.net
Tue Jun 1 09:10:20 CEST 2010


My tp_dealloc method (of non-subtypable type) calls the freeMem-method 
of a memory manager (this manager was also used for the corresponding allocation). 
This freeMem-method deallocates and modifies the memory, 
which is a valid action, because after free, the memory-manager 
has ownership of the freed memory. 
Several memory managers do this (for example the Memory Manager in 
Delphi during debug mode, in order to track invalid memory access after free).

The python31.dll calls tp_alloc and later (after return of tp-alloc) 
the python31.dll is still awaiting valid content in the deallocated memory. 
I don't know where this happens, I'm not a developer of CPython, 
but at this point the python31.dll causes an access violation. 
IMO the python31.dll assumes that freeMem never modifies the memory 
(pyobject header), this is valid for many memory managers, but not for all. 
And from my perspective, this assumption a bug, which can cause access 
violations in many applications (for example, applications which use the 
PythonForDelphi-package; PyScripter is one of them, but also many others) 

Please, could some CPython-developer take a look, thank you!
-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01


More information about the Python-Dev mailing list