mirror of
https://github.com/python/cpython.git
synced 2025-10-05 06:31:48 +00:00
[3.6] bpo-30604: Move co_extra_freefuncs to interpreter state to avoid crashes in threads (#2015)
* Move co_extra_freefuncs to interpreter state to avoid crashes in multi-threaded scenarios involving deletion of code objects * Don't require that extra be zero initialized * Build test list instead of defining empty test class * Ensure extra is always assigned on success * Keep the old fields in the thread state object, just don't use them Add new linked list of code extra objects on a per-interpreter basis so that interpreter state size isn't changed * Rename __PyCodeExtraState_Get and add comment about it going away in 3.7 Fix sort order of import's in test_code.py * Remove an extraneous space * Remove docstrings for comments * Touch up formatting * Fix casing of coextra local * Fix casing of another variable * Prefix PyCodeExtraState with __ to match C API for getting it * Update NEWS file for bpo-30604
This commit is contained in:
parent
f59cac4b64
commit
2997fec01e
6 changed files with 180 additions and 23 deletions
|
@ -5453,14 +5453,14 @@ _Py_GetDXProfile(PyObject *self, PyObject *args)
|
|||
Py_ssize_t
|
||||
_PyEval_RequestCodeExtraIndex(freefunc free)
|
||||
{
|
||||
PyThreadState *tstate = PyThreadState_Get();
|
||||
__PyCodeExtraState *state = __PyCodeExtraState_Get();
|
||||
Py_ssize_t new_index;
|
||||
|
||||
if (tstate->co_extra_user_count == MAX_CO_EXTRA_USERS - 1) {
|
||||
if (state->co_extra_user_count == MAX_CO_EXTRA_USERS - 1) {
|
||||
return -1;
|
||||
}
|
||||
new_index = tstate->co_extra_user_count++;
|
||||
tstate->co_extra_freefuncs[new_index] = free;
|
||||
new_index = state->co_extra_user_count++;
|
||||
state->co_extra_freefuncs[new_index] = free;
|
||||
return new_index;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue