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 vstinner
Recipients vstinner
Date 2021-06-29.02:02:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1624932178.77.0.0459304316784.issue44531@roundup.psfhosted.org>
In-reply-to
Content
The PyType_GenericAlloc() function tracks the newly created object in the garbage collector (GC) as soon as memory is initialized, but before all object members are initialized.

If a GC collection happens before the object is fully initialized, the traverse function of the newly created object can crash.

This case is hypothetical for built-in types since their constructor should not trigger a GC collection. It is more likely in third party extensions and subclasses.

Anyway, I propose to add a new _PyType_AllocNoTrack() function which allocates memory without tracking the newly allocated object directly in the GC.

This function can be used to only track explicitly the object in the GC once it is fully initialized.
History
Date User Action Args
2021-06-29 02:02:58vstinnersetrecipients: + vstinner
2021-06-29 02:02:58vstinnersetmessageid: <1624932178.77.0.0459304316784.issue44531@roundup.psfhosted.org>
2021-06-29 02:02:58vstinnerlinkissue44531 messages
2021-06-29 02:02:58vstinnercreate