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 2020-04-01.21:55:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1585778141.93.0.504215883297.issue40142@roundup.psfhosted.org>
In-reply-to
Content
In bpo-38392, I modified PyObject_GC_Track() to ensure that the object newly tracked is valid: call its traverse function.
=> commit 1b1845569539db5c1a6948a5d32daea381f1e35f

I propose to now also attempt to implement the same check in _PyObject_GC_TRACK() which is part of the internal C API.

PyType_GenericAlloc() allocates memory for a type allocated on the heap... and then immediately track it in the GC. Problem: this type is not initialized yet, all fields are set to zero. Calling type_traverse() at this point fails with an assertion error:
---
Objects/typeobject.c:3570: type_traverse: Assertion failed: type_traverse() called on non-heap type '(null)'
Enable tracemalloc to get the memory block allocation traceback

object address  : 0x840860
object refcount : 1
object type     : 0x7e0900
object type name: type
object repr     : 
---

By the way, Python crash in _PyObject_Dump() on PyObject_Repr() call: type_repr() crash when accessing type->tp_name which is NULL.

type_call() should only track the newly created type when it's fully initialized.


Try attached track.patch to reproduce the crash.
History
Date User Action Args
2020-04-01 21:55:41vstinnersetrecipients: + vstinner
2020-04-01 21:55:41vstinnersetmessageid: <1585778141.93.0.504215883297.issue40142@roundup.psfhosted.org>
2020-04-01 21:55:41vstinnerlinkissue40142 messages
2020-04-01 21:55:41vstinnercreate