mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-130519: Fix crash in QSBR when destructor reenters QSBR (gh-130553)
The `free_work_item()` function in QSBR may call arbitrary code via Python object destructors, which may reenter the QSBR code. Reorder the processing of work items to be robust to reentrancy. Also fix the TODO for the out of memory situation.
This commit is contained in:
parent
5c8e8704c3
commit
45bc120d45
4 changed files with 53 additions and 10 deletions
|
@ -1995,6 +1995,13 @@ is_static_immortal(PyObject *self, PyObject *op)
|
|||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
incref_decref_delayed(PyObject *self, PyObject *op)
|
||||
{
|
||||
_PyObject_XDecRefDelayed(Py_NewRef(op));
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyMethodDef module_functions[] = {
|
||||
{"get_configs", get_configs, METH_NOARGS},
|
||||
{"get_recursion_depth", get_recursion_depth, METH_NOARGS},
|
||||
|
@ -2089,6 +2096,7 @@ static PyMethodDef module_functions[] = {
|
|||
{"has_deferred_refcount", has_deferred_refcount, METH_O},
|
||||
{"get_tracked_heap_size", get_tracked_heap_size, METH_NOARGS},
|
||||
{"is_static_immortal", is_static_immortal, METH_O},
|
||||
{"incref_decref_delayed", incref_decref_delayed, METH_O},
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue