mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
[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 47fb4327b5
)
This commit is contained in:
parent
ca37034baa
commit
ae705319fc
9 changed files with 30 additions and 44 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue