Skip to content

Commit 5a39cb7

Browse files
committed
add TODO note to remove casts to destructor
1 parent a197210 commit 5a39cb7

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Include/cpython/object.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,8 @@ PyAPI_FUNC(int) _Py_ReachedRecursionLimitWithMargin(PyThreadState *tstate, int m
494494
#define Py_TRASHCAN_BEGIN(op, dealloc) \
495495
do { \
496496
PyThreadState *tstate = PyThreadState_Get(); \
497-
if (_Py_ReachedRecursionLimitWithMargin(tstate, 2) && Py_TYPE(op)->tp_dealloc == (destructor)dealloc) { \
497+
/* TODO(picnixz): remove '(destructor)' cast to detect runtime UBs */ \
498+
if (tstate->c_recursion_remaining <= Py_TRASHCAN_HEADROOM && Py_TYPE(op)->tp_dealloc == (destructor)dealloc) { \
498499
_PyTrash_thread_deposit_object(tstate, (PyObject *)op); \
499500
break; \
500501
}

Python/ceval.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
_Py_DECREF_STAT_INC(); \
103103
if (--op->ob_refcnt == 0) { \
104104
_PyReftracerTrack(op, PyRefTracer_DESTROY); \
105+
/* TODO(picnixz): remove '(destructor)' cast to detect runtime UBs */ \
105106
destructor d = (destructor)(dealloc); \
106107
d(op); \
107108
} \

0 commit comments

Comments
 (0)