[New-bugs-announce] [issue33803] contextvars: hamt_alloc() must initialize h_root and h_count fields

STINNER Victor report at bugs.python.org
Thu Jun 7 19:44:54 EDT 2018


New submission from STINNER Victor <vstinner at redhat.com>:

test_asyncio started to crash in https://github.com/python/cpython/pull/7487

I debugged the crash with Yury: _PyHAMT_New() triggers indirectly a GC collection at "o->h_root = hamt_node_bitmap_new(0);". Problem: the object that is being created is already tracked by the GC, whereas its h_root field is not set. Then the GC does crash because the field is a random pointer.

hamt_alloc() must initialize h_root and h_count before tracking the object in the GC.

Thinking about the GC when writing an object constructor is hard :-(

Maybe we should add a debug option to trigger the GC more often to make such random bug more likely. contextvars has been implemented a few months ago, and we only spotted the bug a few days before Python 3.7.0 final release...

----------
components: Interpreter Core
messages: 318990
nosy: ned.deily, vstinner, yselivanov
priority: release blocker
severity: normal
status: open
type: crash
versions: Python 3.7, Python 3.8

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


More information about the New-bugs-announce mailing list