mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
bpo-35983: skip trashcan for subclasses (GH-11841)
Add new trashcan macros to deal with a double deallocation that could occur when the `tp_dealloc` of a subclass calls the `tp_dealloc` of a base class and that base class uses the trashcan mechanism. Patch by Jeroen Demeyer.
This commit is contained in:
parent
a2fedd8c91
commit
351c67416b
15 changed files with 189 additions and 121 deletions
|
@ -361,7 +361,7 @@ list_dealloc(PyListObject *op)
|
|||
{
|
||||
Py_ssize_t i;
|
||||
PyObject_GC_UnTrack(op);
|
||||
Py_TRASHCAN_SAFE_BEGIN(op)
|
||||
Py_TRASHCAN_BEGIN(op, list_dealloc)
|
||||
if (op->ob_item != NULL) {
|
||||
/* Do it backwards, for Christian Tismer.
|
||||
There's a simple test case where somehow this reduces
|
||||
|
@ -377,7 +377,7 @@ list_dealloc(PyListObject *op)
|
|||
free_list[numfree++] = op;
|
||||
else
|
||||
Py_TYPE(op)->tp_free((PyObject *)op);
|
||||
Py_TRASHCAN_SAFE_END(op)
|
||||
Py_TRASHCAN_END
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue