mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-129701: Fix a data race in intern_common
in the free threaded build (GH-130089)
* gh-129701: Fix a data race in `intern_common` in the free threaded build * Use a mutex to avoid potentially returning a non-immortalized string, because immortalization happens after the insertion into the interned dict. * Use `Py_DECREF()` calls instead of `Py_SET_REFCNT(s, Py_REFCNT(s) - 2)` for thread-safety. This code path isn't performance sensistive, so just use `Py_DECREF()` unconditionally for simplicity.
This commit is contained in:
parent
fc8c99a8ce
commit
b9d2ee687c
2 changed files with 17 additions and 6 deletions
|
@ -64,6 +64,9 @@ struct _Py_static_objects {
|
|||
(interp)->cached_objects.NAME
|
||||
|
||||
struct _Py_interp_cached_objects {
|
||||
#ifdef Py_GIL_DISABLED
|
||||
PyMutex interned_mutex;
|
||||
#endif
|
||||
PyObject *interned_strings;
|
||||
|
||||
/* object.__reduce__ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue