◐ Shell
clean mode source ↗

[3.13] gh-120524: Avoid a Race On _PyRuntime.types.managed_static.types[i].interp_count (gh-120529) by miss-islington · Pull Request #120657 · python/cpython

Expand Up @@ -246,7 +246,8 @@ managed_static_type_state_init(PyInterpreterState *interp, PyTypeObject *self,
assert((initial == 1) == (_PyRuntime.types.managed_static.types[full_index].interp_count == 0)); _PyRuntime.types.managed_static.types[full_index].interp_count += 1; (void)_Py_atomic_add_int64( &_PyRuntime.types.managed_static.types[full_index].interp_count, 1);
if (initial) { assert(_PyRuntime.types.managed_static.types[full_index].type == NULL); Expand Down Expand Up @@ -300,7 +301,8 @@ managed_static_type_state_clear(PyInterpreterState *interp, PyTypeObject *self, state->type = NULL; assert(state->tp_weaklist == NULL); // It was already cleared out.
_PyRuntime.types.managed_static.types[full_index].interp_count -= 1; (void)_Py_atomic_add_int64( &_PyRuntime.types.managed_static.types[full_index].interp_count, -1); if (final) { assert(!_PyRuntime.types.managed_static.types[full_index].interp_count); _PyRuntime.types.managed_static.types[full_index].type = NULL; Expand Down