mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +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
|
@ -2433,7 +2433,7 @@ _PyObject_SetDeferredRefcount(PyObject *op)
|
|||
assert(op->ob_ref_shared == 0);
|
||||
_PyObject_SET_GC_BITS(op, _PyGC_BITS_DEFERRED);
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
if (interp->gc.immortalize.enabled) {
|
||||
if (_Py_atomic_load_int_relaxed(&interp->gc.immortalize) == 1) {
|
||||
// gh-117696: immortalize objects instead of using deferred reference
|
||||
// counting for now.
|
||||
_Py_SetImmortal(op);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue