diff options
Diffstat (limited to 'Python')
| -rw-r--r-- | Python/gc_free_threading.c | 4 | ||||
| -rw-r--r-- | Python/pystate.c | 8 | 
2 files changed, 10 insertions, 2 deletions
| diff --git a/Python/gc_free_threading.c b/Python/gc_free_threading.c index 7e4137a..111632f 100644 --- a/Python/gc_free_threading.c +++ b/Python/gc_free_threading.c @@ -168,7 +168,7 @@ merge_refcount(PyObject *op, Py_ssize_t extra)      refcount += extra;  #ifdef Py_REF_DEBUG -    _Py_AddRefTotal(_PyInterpreterState_GET(), extra); +    _Py_AddRefTotal(_PyThreadState_GET(), extra);  #endif      // No atomics necessary; all other threads in this interpreter are paused. @@ -307,7 +307,7 @@ merge_queued_objects(_PyThreadStateImpl *tstate, struct collection_state *state)              // decref and deallocate the object once we start the world again.              op->ob_ref_shared += (1 << _Py_REF_SHARED_SHIFT);  #ifdef Py_REF_DEBUG -            _Py_IncRefTotal(_PyInterpreterState_GET()); +            _Py_IncRefTotal(_PyThreadState_GET());  #endif              worklist_push(&state->objs_to_decref, op);          } diff --git a/Python/pystate.c b/Python/pystate.c index cee481c..4a52f64 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -1698,6 +1698,14 @@ tstate_delete_common(PyThreadState *tstate)              decrement_stoptheworld_countdown(&runtime->stoptheworld);          }      } + +#if defined(Py_REF_DEBUG) && defined(Py_GIL_DISABLED) +    // Add our portion of the total refcount to the interpreter's total. +    _PyThreadStateImpl *tstate_impl = (_PyThreadStateImpl *)tstate; +    tstate->interp->object_state.reftotal += tstate_impl->reftotal; +    tstate_impl->reftotal = 0; +#endif +      HEAD_UNLOCK(runtime);  #ifdef Py_GIL_DISABLED | 
