[issue36389] Add gc.enable_object_debugger(): detect corrupted Python objects in the GC

STINNER Victor report at bugs.python.org
Wed Apr 10 22:18:16 EDT 2019


STINNER Victor <vstinner at redhat.com> added the comment:

bpo-33803 bug can be reintroduced using the following patch:

diff --git a/Python/hamt.c b/Python/hamt.c
index 67af04c437..67da8ec22c 100644
--- a/Python/hamt.c
+++ b/Python/hamt.c
@@ -2478,8 +2478,10 @@ hamt_alloc(void)
     if (o == NULL) {
         return NULL;
     }
+#if 0
     o->h_count = 0;
     o->h_root = NULL;
+#endif
     o->h_weakreflist = NULL;
     PyObject_GC_Track(o);
     return o;

And then run:

./python -m test -v test_context

The best would be to also be able to catch the bug in:

./python -m test -v test_asyncio

Problem: Right now, my GC object debugger implementation is way too slow to use a threshold lower than 100, whereas the bug is catched like "immediately" using gc.set_threshold(5).

Maybe my implementation should be less naive: rather than always check *all* objects tracked by the GC, have different thresholds depending on the generation? Maybe reuse GC thresholds?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36389>
_______________________________________


More information about the Python-bugs-list mailing list