diff options
| author | Dino Viehland <dinoviehland@meta.com> | 2024-03-08 17:56:36 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-08 17:56:36 (GMT) |
| commit | 7db871e4fa48eef20ea22414b226998f83facfd6 (patch) | |
| tree | 6b0b81db65dbf71864138847f32978cb831eeaed /Python/gc_free_threading.c | |
| parent | 61831585b637eb621bc80ae39e2e59541c135dc5 (diff) | |
| download | cpython-7db871e4fa48eef20ea22414b226998f83facfd6.zip cpython-7db871e4fa48eef20ea22414b226998f83facfd6.tar.gz cpython-7db871e4fa48eef20ea22414b226998f83facfd6.tar.bz2 | |
gh-112075: Support freeing object memory via QSBR (#116344)
Free objects with qsbr if shared
Diffstat (limited to 'Python/gc_free_threading.c')
| -rw-r--r-- | Python/gc_free_threading.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Python/gc_free_threading.c b/Python/gc_free_threading.c index c7883cd..59e7601 100644 --- a/Python/gc_free_threading.c +++ b/Python/gc_free_threading.c @@ -1695,6 +1695,7 @@ PyObject_GC_Del(void *op) { size_t presize = _PyType_PreHeaderSize(((PyObject *)op)->ob_type); if (_PyObject_GC_IS_TRACKED(op)) { + _PyObject_GC_UNTRACK(op); #ifdef Py_DEBUG PyObject *exc = PyErr_GetRaisedException(); if (PyErr_WarnExplicitFormat(PyExc_ResourceWarning, "gc", 0, @@ -1707,8 +1708,13 @@ PyObject_GC_Del(void *op) } record_deallocation(_PyThreadState_GET()); - - PyObject_Free(((char *)op)-presize); + PyObject *self = (PyObject *)op; + if (_PyObject_GC_IS_SHARED_INLINE(self)) { + _PyObject_FreeDelayed(((char *)op)-presize); + } + else { + PyObject_Free(((char *)op)-presize); + } } int |
