Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upbpo-38392: PyObject_GC_Track() validates object in debug mode #16615
Conversation
This comment has been minimized.
This comment has been minimized.
This change is backward incompatible and I'm not sure that it's a good idea, so I marked is a WIP. See https://bugs.python.org/issue38392 for the rationale an discussion. |
LGTM. Please add a NEWS entry. |
This comment has been minimized.
This comment has been minimized.
Should I add an entry in What's New in Python 3.9? |
This comment has been minimized.
This comment has been minimized.
This change does not change the documented behavior. So I think that an entry in NEWS would be enough. If you used |
In debug mode, PyObject_GC_Track() now calls tp_traverse() of the object type to ensure that the object is valid: test that objects visited by tp_traverse() are valid. Fix pyexpat.c: only track the parser in the GC once the parser is fully initialized.
This comment has been minimized.
This comment has been minimized.
I modified my PR: if a bug is detected, _PyObject_ASSERT_FAILED_MSG() now gets the object passed to PyObject_GC_Track(). This object is more likely to help the developer debugging an issue, rather than displaying the visited object which is invalid and may only be displayed as "" without any further information. I reintroduced https://bugs.python.org/issue33803 bug with this patch:
The hamt bug is immediately detected. Example (with tracemalloc enabled):
Note, when tracemalloc is disabled (default), this reminder is logged:
|
Onyly track the object in the GC once it's fully initialized.
vstinner commentedOct 7, 2019
•
edited by bedevere-bot
In debug mode, PyObject_GC_Track() now calls tp_traverse() of the
object to ensure that all object attributes visited by tp_traverse()
are initialized.
Fix pyexpat.c: only track the parser in the GC once the parser is
fully initialized.
https://bugs.python.org/issue38392