Skip to content

Commit 73ee5a6

Browse files
GH-94851: check refcnt of immortal objects after finalization (GH-95001)
1 parent ac6a94c commit 73ee5a6

File tree

4 files changed

+4430
-1
lines changed

4 files changed

+4430
-1
lines changed

Include/internal/pycore_object.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ extern "C" {
1414
#include "pycore_pystate.h" // _PyInterpreterState_GET()
1515
#include "pycore_runtime.h" // _PyRuntime
1616

17+
/* This value provides *effective* immortality, meaning the object should never
18+
be deallocated (until runtime finalization). See PEP 683 for more details about
19+
immortality, as well as a proposed mechanism for proper immortality. */
20+
#define _PyObject_IMMORTAL_REFCNT 999999999
21+
1722
#define _PyObject_IMMORTAL_INIT(type) \
1823
{ \
19-
.ob_refcnt = 999999999, \
24+
.ob_refcnt = _PyObject_IMMORTAL_REFCNT, \
2025
.ob_type = (type), \
2126
}
2227
#define _PyVarObject_IMMORTAL_INIT(type, size) \

0 commit comments

Comments
 (0)