mirror of
https://github.com/python/cpython.git
synced 2025-08-23 18:24:46 +00:00
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.
This commit is contained in:
parent
e74fa294c9
commit
ae460d450a
11 changed files with 500 additions and 80 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue