Skip to content

Commit 04d3398

Browse files
committed
Mark immortal objects as deferred
1 parent 49f2465 commit 04d3398

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

Include/internal/pycore_object.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ PyAPI_FUNC(int) _PyObject_IsFreed(PyObject *);
7474
{ \
7575
.ob_ref_local = _Py_IMMORTAL_REFCNT_LOCAL, \
7676
.ob_flags = _Py_STATICALLY_ALLOCATED_FLAG, \
77+
.ob_gc_bits = _PyGC_BITS_DEFERRED, \
7778
.ob_type = (type) \
7879
}
7980
#else

Include/internal/pycore_stackref.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ PyStackRef_FromPyObjectNew(PyObject *obj)
219219
// Make sure we don't take an already tagged value.
220220
assert(((uintptr_t)obj & Py_TAG_BITS) == 0);
221221
assert(obj != NULL);
222-
if (_Py_IsImmortal(obj) || _PyObject_HasDeferredRefcount(obj)) {
222+
if (_PyObject_HasDeferredRefcount(obj)) {
223223
return (_PyStackRef){ .bits = (uintptr_t)obj | Py_TAG_DEFERRED };
224224
}
225225
else {

Objects/object.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2531,6 +2531,7 @@ _Py_SetImmortalUntracked(PyObject *op)
25312531
op->ob_tid = _Py_UNOWNED_TID;
25322532
op->ob_ref_local = _Py_IMMORTAL_REFCNT_LOCAL;
25332533
op->ob_ref_shared = 0;
2534+
_Py_atomic_or_uint8(&op->ob_gc_bits, _PyGC_BITS_DEFERRED);
25342535
#else
25352536
op->ob_refcnt = _Py_IMMORTAL_INITIAL_REFCNT;
25362537
#endif

0 commit comments

Comments
 (0)