summaryrefslogtreecommitdiffstats
path: root/Python/pystate.c
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-06-03 20:58:41 (GMT)
committerGitHub <noreply@github.com>2024-06-03 20:58:41 (GMT)
commit47fb4327b5c405da6df066dcaa01b7c1aefab313 (patch)
tree8b5e04508b3cdced61e56eb200c4fc46a50ed11d /Python/pystate.c
parentb8fde5db86334690da23343f5f4326adcd8160fb (diff)
downloadcpython-47fb4327b5c405da6df066dcaa01b7c1aefab313.zip
cpython-47fb4327b5c405da6df066dcaa01b7c1aefab313.tar.gz
cpython-47fb4327b5c405da6df066dcaa01b7c1aefab313.tar.bz2
gh-117657: Fix race involving immortalizing objects (#119927)
The free-threaded build currently immortalizes objects that use deferred reference counting (see gh-117783). This typically happens once the first non-main thread is created, but the behavior can be suppressed for tests, in subinterpreters, or during a compile() call. This fixes a race condition involving the tracking of whether the behavior is suppressed.
Diffstat (limited to 'Python/pystate.c')
-rw-r--r--Python/pystate.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index 36e4206..d029391 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -1583,9 +1583,7 @@ new_threadstate(PyInterpreterState *interp, int whence)
}
else {
#ifdef Py_GIL_DISABLED
- if (interp->gc.immortalize.enable_on_thread_created &&
- !interp->gc.immortalize.enabled)
- {
+ if (_Py_atomic_load_int(&interp->gc.immortalize) == 0) {
// Immortalize objects marked as using deferred reference counting
// the first time a non-main thread is created.
_PyGC_ImmortalizeDeferredObjects(interp);