Message354172
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)
--- |
|
Date |
User |
Action |
Args |
2019-10-08 07:09:47 | vstinner | set | recipients:
+ vstinner, ned.deily, yselivanov |
2019-10-08 07:09:47 | vstinner | set | messageid: <1570518587.37.0.14508720594.issue33803@roundup.psfhosted.org> |
2019-10-08 07:09:47 | vstinner | link | issue33803 messages |
2019-10-08 07:09:46 | vstinner | create | |
|