STINNER Victor <vstin...@python.org> added the comment:
Notes for myself. In bpo-38392, I modified PyObject_GC_Track() in debug mode to detect this bug. For example, this bug can be reproduced with this change: --- diff --git a/Python/hamt.c b/Python/hamt.c index 28b4e1ef6c..d7dd555d15 100644 --- a/Python/hamt.c +++ b/Python/hamt.c @@ -2478,8 +2478,6 @@ hamt_alloc(void) if (o == NULL) { return NULL; } - o->h_count = 0; - o->h_root = NULL; o->h_weakreflist = NULL; PyObject_GC_Track(o); return o; --- Python now detects the bug in debug mode: --- $ ./python -m test -v test_context (...) test_context_copy_1 (test.test_context.ContextTest) ... Modules/gcmodule.c:1931: visit_validate: Assertion failed: PyObject_GC_Track() object is not valid Enable tracemalloc to get the memory block allocation traceback object address : 0x7f2b17408d70 object refcount : 1 object type : 0x76bc20 object type name: hamt object repr : <hamt object at 0x7f2b17408d70> Fatal Python error: _PyObject_AssertFailed Python runtime state: initialized Current thread 0x00007f2b25590740 (most recent call first): File "/home/vstinner/python/master/Lib/test/test_context.py", line 322 in test_context_copy_1 File "/home/vstinner/python/master/Lib/unittest/case.py", line 616 in _callTestMethod File "/home/vstinner/python/master/Lib/unittest/case.py", line 659 in run (...) File "/home/vstinner/python/master/Lib/runpy.py", line 192 in _run_module_as_main Aborted (core dumped) --- ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33803> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com