[issue33583] PyObject_GC_Resize() doesn't relink GCHead

INADA Naoki report at bugs.python.org
Sun May 20 03:42:31 EDT 2018


New submission from INADA Naoki <songofacandy at gmail.com>:

https://github.com/python/cpython/blob/master/Modules/gcmodule.c#L1750-L1763

PyObject_GC_Resize() calls PyObject_REALLOC(), which can change object's address.
But it doesn't relinking:

 g->gc.gc_prev->gc.gc_next = g
 g->gc.gc_next->gc.gc_prev = g

So this API can't be used for tracked object.
In CPython code, all callers use this API for non tracked objects.

But if some extension module author used this API for tracked objects, it will cause hard to debug behavior.

Which should we do?

1. Add relinking to PyObject_GC_Resize()
2. Add note in the document

If 1, should we backport it to 3.7 and 3.6?

----------
components: Interpreter Core
messages: 317158
nosy: inada.naoki
priority: normal
severity: normal
status: open
title: PyObject_GC_Resize() doesn't relink GCHead
type: behavior

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


More information about the Python-bugs-list mailing list