This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author davide.rizzo
Recipients amaury.forgeotdarc, benjamin.peterson, davide.rizzo, ezio.melotti, orsenthil, pitrou, vstinner
Date 2011-07-05.23:14:41
SpamBayes Score 9.992007e-16
Marked as misclassified No
Message-id <1309907682.06.0.044959518295.issue12149@psf.upfronthosting.co.za>
In-reply-to
Content
Looking through Antoine's example code. When garbage is collected, the subtype and its tp_dict are cleared before the instance object itself. When the dict is cleared as part of the garbage collection, the methods get deallocated but the method cache is not updated. That way the lookup for the "close" method results in a cache hit for an invalid pointer.

I'm not at all knowledgeable to understand whether it is right for the type dictionary to be cleared before instances of that type (then either the finalizer for IOBase should work around this case, or the cache should be updated beforehand), or there is something to be done to ensure a correct clearing order.

Also I can't think of any other example of a C type, inheritable from Python code, that calls another method in the destructor: is this specific to IO? Please note that the example code fails even when inheriting from the C type directly (_io._IOBase).
History
Date User Action Args
2011-07-05 23:14:42davide.rizzosetrecipients: + davide.rizzo, amaury.forgeotdarc, orsenthil, pitrou, vstinner, benjamin.peterson, ezio.melotti
2011-07-05 23:14:42davide.rizzosetmessageid: <1309907682.06.0.044959518295.issue12149@psf.upfronthosting.co.za>
2011-07-05 23:14:41davide.rizzolinkissue12149 messages
2011-07-05 23:14:41davide.rizzocreate