mirror of
https://github.com/python/cpython.git
synced 2025-12-09 18:48:05 +00:00
gh-117439: Make refleak checking thread-safe without the GIL (#117469)
This keeps track of the per-thread total reference count operations in PyThreadState in the free-threaded builds. The count is merged into the interpreter's total when the thread exits.
This commit is contained in:
parent
2067da2579
commit
1a6594f661
9 changed files with 62 additions and 44 deletions
|
|
@ -445,7 +445,7 @@ dictkeys_incref(PyDictKeysObject *dk)
|
|||
return;
|
||||
}
|
||||
#ifdef Py_REF_DEBUG
|
||||
_Py_IncRefTotal(_PyInterpreterState_GET());
|
||||
_Py_IncRefTotal(_PyThreadState_GET());
|
||||
#endif
|
||||
INCREF_KEYS(dk);
|
||||
}
|
||||
|
|
@ -458,7 +458,7 @@ dictkeys_decref(PyInterpreterState *interp, PyDictKeysObject *dk, bool use_qsbr)
|
|||
}
|
||||
assert(dk->dk_refcnt > 0);
|
||||
#ifdef Py_REF_DEBUG
|
||||
_Py_DecRefTotal(_PyInterpreterState_GET());
|
||||
_Py_DecRefTotal(_PyThreadState_GET());
|
||||
#endif
|
||||
if (DECREF_KEYS(dk) == 1) {
|
||||
if (DK_IS_UNICODE(dk)) {
|
||||
|
|
@ -790,7 +790,7 @@ new_keys_object(PyInterpreterState *interp, uint8_t log2_size, bool unicode)
|
|||
}
|
||||
}
|
||||
#ifdef Py_REF_DEBUG
|
||||
_Py_IncRefTotal(_PyInterpreterState_GET());
|
||||
_Py_IncRefTotal(_PyThreadState_GET());
|
||||
#endif
|
||||
dk->dk_refcnt = 1;
|
||||
dk->dk_log2_size = log2_size;
|
||||
|
|
@ -978,7 +978,7 @@ clone_combined_dict_keys(PyDictObject *orig)
|
|||
we have it now; calling dictkeys_incref would be an error as
|
||||
keys->dk_refcnt is already set to 1 (after memcpy). */
|
||||
#ifdef Py_REF_DEBUG
|
||||
_Py_IncRefTotal(_PyInterpreterState_GET());
|
||||
_Py_IncRefTotal(_PyThreadState_GET());
|
||||
#endif
|
||||
return keys;
|
||||
}
|
||||
|
|
@ -2021,7 +2021,7 @@ dictresize(PyInterpreterState *interp, PyDictObject *mp,
|
|||
|
||||
if (oldkeys != Py_EMPTY_KEYS) {
|
||||
#ifdef Py_REF_DEBUG
|
||||
_Py_DecRefTotal(_PyInterpreterState_GET());
|
||||
_Py_DecRefTotal(_PyThreadState_GET());
|
||||
#endif
|
||||
assert(oldkeys->dk_kind != DICT_KEYS_SPLIT);
|
||||
assert(oldkeys->dk_refcnt == 1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue