diff options
| author | Dino Viehland <dinoviehland@meta.com> | 2024-02-15 18:54:57 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-15 18:54:57 (GMT) |
| commit | ae460d450ab854ca66d509ef6971cfe1b6312405 (patch) | |
| tree | 25cbb65be2f0f0779ff37174751026e8fd262dde /Python/pystate.c | |
| parent | e74fa294c9b0c67bfcbefdda5a069f0a7648f524 (diff) | |
| download | cpython-ae460d450ab854ca66d509ef6971cfe1b6312405.zip cpython-ae460d450ab854ca66d509ef6971cfe1b6312405.tar.gz cpython-ae460d450ab854ca66d509ef6971cfe1b6312405.tar.bz2 | |
gh-113743: Make the MRO cache thread-safe in free-threaded builds (#113930)
Makes _PyType_Lookup thread safe, including:
Thread safety of the underlying cache.
Make mutation of mro and type members thread safe
Also _PyType_GetMRO and _PyType_GetBases are currently returning borrowed references which aren't safe.
Diffstat (limited to 'Python/pystate.c')
| -rw-r--r-- | Python/pystate.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Python/pystate.c b/Python/pystate.c index 08ec586..b1d1a08 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -395,6 +395,7 @@ _Py_COMP_DIAG_POP &(runtime)->atexit.mutex, \ &(runtime)->audit_hooks.mutex, \ &(runtime)->allocators.mutex, \ + &(runtime)->types.type_mutex, \ } static void @@ -499,6 +500,8 @@ _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime) _PyMutex_at_fork_reinit(locks[i]); } + _PyTypes_AfterFork(); + /* bpo-42540: id_mutex is freed by _PyInterpreterState_Delete, which does * not force the default allocator. */ if (_PyThread_at_fork_reinit(&runtime->interpreters.main->id_mutex) < 0) { |
