summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Python/pystate.c
diff options
context:
space:
mode:
authorshadchin <[email protected]>2026-02-07 19:56:35 +0300
committershadchin <[email protected]>2026-02-07 20:23:53 +0300
commit19d43a3e6fb4cb8ea11747d7d7bca7a3542fbb44 (patch)
tree0b1418938140a0b6470953bef6069454ffdf1bd0 /contrib/tools/python3/Python/pystate.c
parent0879409bfc0891ab8103828a3bdbf0e960475fec (diff)
Update Python 3 to 3.13.12
commit_hash:71d3efea437a769b2b7910d196120bb02587046e
Diffstat (limited to 'contrib/tools/python3/Python/pystate.c')
-rw-r--r--contrib/tools/python3/Python/pystate.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/contrib/tools/python3/Python/pystate.c b/contrib/tools/python3/Python/pystate.c
index 2b1bff7f108..85c20ead488 100644
--- a/contrib/tools/python3/Python/pystate.c
+++ b/contrib/tools/python3/Python/pystate.c
@@ -1748,6 +1748,14 @@ PyThreadState_Clear(PyThreadState *tstate)
// Remove ourself from the biased reference counting table of threads.
_Py_brc_remove_thread(tstate);
+
+ // Flush the thread's local GC allocation count to the global count
+ // before the thread state is cleared, otherwise the count is lost.
+ _PyThreadStateImpl *tstate_impl = (_PyThreadStateImpl *)tstate;
+ _Py_atomic_add_int(&tstate->interp->gc.generations[0].count,
+ (int)tstate_impl->gc.alloc_count);
+ tstate_impl->gc.alloc_count = 0;
+
#endif
// Merge our queue of pointers to be freed into the interpreter queue.