summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authormpage <mpage@meta.com>2024-07-19 17:22:02 (GMT)
committerGitHub <noreply@github.com>2024-07-19 17:22:02 (GMT)
commite059aa6b01030310125477c3ed1da0491020fe10 (patch)
treec62b22c966cfa6cdd0d53779d3e9ad965713bf2e /Include
parent2009e25e26040dca32696e70f91f13665350e7fd (diff)
downloadcpython-e059aa6b01030310125477c3ed1da0491020fe10.zip
cpython-e059aa6b01030310125477c3ed1da0491020fe10.tar.gz
cpython-e059aa6b01030310125477c3ed1da0491020fe10.tar.bz2
gh-120973: Fix thread-safety issues with `threading.local` (#121655)
This is a small refactoring to the current design that allows us to avoid manually iterating over threads. This should also fix gh-118490.
Diffstat (limited to 'Include')
-rw-r--r--Include/cpython/pystate.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index bb2af78..f005729 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -192,6 +192,14 @@ struct _ts {
PyObject *previous_executor;
uint64_t dict_global_version;
+
+ /* Used to store/retrieve `threading.local` keys/values for this thread */
+ PyObject *threading_local_key;
+
+ /* Used by `threading.local`s to be remove keys/values for dying threads.
+ The PyThreadObject must hold the only reference to this value.
+ */
+ PyObject *threading_local_sentinel;
};
#ifdef Py_DEBUG