diff options
| author | Sam Gross <colesbury@gmail.com> | 2021-11-17 22:53:33 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-17 22:53:33 (GMT) |
| commit | 87787c8774221c81602b31b0e0dc0678ad494e91 (patch) | |
| tree | 74170d3e701298c60a4c10b64342df1d5f807442 /Python | |
| parent | ac89f8cab79800195687dd141de472f90c626ec3 (diff) | |
| download | cpython-87787c8774221c81602b31b0e0dc0678ad494e91.zip cpython-87787c8774221c81602b31b0e0dc0678ad494e91.tar.gz cpython-87787c8774221c81602b31b0e0dc0678ad494e91.tar.bz2 | |
[3.9] bpo-42540: reallocation of id_mutex should not force default allocator (GH-29564) (GH-29600)
Unlike the other locks reinitialized by _PyRuntimeState_ReInitThreads,
the "interpreters.main->id_mutex" is not freed by _PyRuntimeState_Fini
and should not force the default raw allocator..
(cherry picked from commit 736684b1bb67369a2e95a9f621752deead44e7ef)
Co-authored-by: Sam Gross <colesbury@gmail.com>
Diffstat (limited to 'Python')
| -rw-r--r-- | Python/pystate.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Python/pystate.c b/Python/pystate.c index 9beefa8..c3520c3 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -139,11 +139,14 @@ _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime) _PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc); int interp_mutex = _PyThread_at_fork_reinit(&runtime->interpreters.mutex); - int main_interp_id_mutex = _PyThread_at_fork_reinit(&runtime->interpreters.main->id_mutex); int xidregistry_mutex = _PyThread_at_fork_reinit(&runtime->xidregistry.mutex); PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc); + /* bpo-42540: id_mutex is freed by _PyInterpreterState_Delete, which does + * not force the default allocator. */ + int main_interp_id_mutex = _PyThread_at_fork_reinit(&runtime->interpreters.main->id_mutex); + if (interp_mutex < 0) { Py_FatalError("Can't initialize lock for runtime interpreters"); } |
