New submission from STINNER Victor <vstin...@python.org>:
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. ---------- components: C API messages: 396695 nosy: vstinner priority: normal severity: normal status: open title: Add _PyType_AllocNoTrack() function: allocate without tracking in the GC versions: Python 3.11 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44531> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com