diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-11-17 21:16:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-17 21:16:01 (GMT) |
commit | 1079b3e3cb3eba7062e174ecc6c0ab20c2d0722e (patch) | |
tree | df58ef9fb98a902a9b8a8e8d56eaec04fd188083 /Python | |
parent | 5618c81e139419b4665dc1f1e8a468738546f542 (diff) | |
download | cpython-1079b3e3cb3eba7062e174ecc6c0ab20c2d0722e.zip cpython-1079b3e3cb3eba7062e174ecc6c0ab20c2d0722e.tar.gz cpython-1079b3e3cb3eba7062e174ecc6c0ab20c2d0722e.tar.bz2 |
bpo-42540: reallocation of id_mutex should not force default allocator (GH-29564)
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 aeebd6f..df98eb1 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -147,12 +147,15 @@ _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime) _PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc); int reinit_interp = _PyThread_at_fork_reinit(&runtime->interpreters.mutex); - int reinit_main_id = _PyThread_at_fork_reinit(&runtime->interpreters.main->id_mutex); int reinit_xidregistry = _PyThread_at_fork_reinit(&runtime->xidregistry.mutex); int reinit_unicode_ids = _PyThread_at_fork_reinit(&runtime->unicode_ids.lock); PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc); + /* bpo-42540: id_mutex is freed by _PyInterpreterState_Delete, which does + * not force the default allocator. */ + int reinit_main_id = _PyThread_at_fork_reinit(&runtime->interpreters.main->id_mutex); + if (reinit_interp < 0 || reinit_main_id < 0 || reinit_xidregistry < 0 |