STINNER Victor <vstin...@python.org> added the comment:

> It could be possible to do this in backward compatible way. 
> PyObject_GC_Track() could add the object to the list of new objects (all 
> objects are already linked in bi-linked list, so it would need to just move 
> the object to the specified list), and PyObject_GC_NewVar() could check all 
> new objects and clear the list of new objects (just move the head).

That's different than what I'm proposing here. Checking "later" is more on the 
bpo-36389 side: my bpo-36389 PR modified PyObject_GC_NewVar() to check that 
young object are valid.

Moreover, my bpo-36389 PR required threshold: checking all young objects at 
each PyObject_GC_NewVar() simply killed performance which made the whole 
approach unusable in practice. Because of the threshold, my implementation 
failed to detect the hamt.c bug bpo-33803: the partially initialized was 
already fully initialized when my "object debugger" ran. PR 16615 detects 
immediately the hamt.c bug bpo-33803.

I designed bpo-36389 to attempt to detect when an object is corrupted after its 
creation, corrupted by code running "later".

We had a customer with a bug in OpenStack Nova. Nova crashed in visit_decref() 
but I failed to debug the issue. It motivated me to modify the debug ABI in 
Python 3.8, so later it will become possible to switch from release to debug 
mode to attempt to debug a program using additional checks added by the debug 
build.

Here my intent is to ensure that objects entering the GC are valid to help to 
keep the GC list consistent and valid. But it doesn't prevent an object from 
being corrupted after its creation. We should try to find a different approach 
for that (maybe revisit bpo-36389).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38392>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to