summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-06-03 22:21:32 (GMT)
committerGitHub <noreply@github.com>2024-06-03 22:21:32 (GMT)
commitae705319fcde864b504987dc8e579e3eef68e1e5 (patch)
tree022166446a352d99b784b44a86f163bec179e94d /Include
parentca37034baa2909722df58c02dfd13e1d667252ce (diff)
downloadcpython-ae705319fcde864b504987dc8e579e3eef68e1e5.zip
cpython-ae705319fcde864b504987dc8e579e3eef68e1e5.tar.gz
cpython-ae705319fcde864b504987dc8e579e3eef68e1e5.tar.bz2
[3.13] gh-117657: Fix race involving immortalizing objects (GH-119927) (#120005)
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. (cherry picked from commit 47fb4327b5c405da6df066dcaa01b7c1aefab313)
Diffstat (limited to 'Include')
-rw-r--r--Include/internal/pycore_gc.h14
1 files changed, 5 insertions, 9 deletions
diff --git a/Include/internal/pycore_gc.h b/Include/internal/pycore_gc.h
index 6058252..ba8b8e1 100644
--- a/Include/internal/pycore_gc.h
+++ b/Include/internal/pycore_gc.h
@@ -347,15 +347,11 @@ struct _gc_runtime_state {
/* gh-117783: Deferred reference counting is not fully implemented yet, so
as a temporary measure we treat objects using deferred referenence
- counting as immortal. */
- struct {
- /* Immortalize objects instead of marking them as using deferred
- reference counting. */
- int enabled;
-
- /* Set enabled=1 when the first background thread is created. */
- int enable_on_thread_created;
- } immortalize;
+ counting as immortal. The value may be zero, one, or a negative number:
+ 0: immortalize deferred RC objects once the first thread is created
+ 1: immortalize all deferred RC objects immediately
+ <0: suppressed; don't immortalize objects */
+ int immortalize;
#endif
};