Skip to content

Commit

Permalink
pythongh-113753: Clear finalized bit when allocating PyAsyncGenASend …
Browse files Browse the repository at this point in the history
…from free-list
  • Loading branch information
colesbury committed Jan 5, 2024
1 parent 99854ce commit 7ae71e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Include/internal/pycore_gc.h
Expand Up @@ -120,6 +120,10 @@ static inline void _PyGC_SET_FINALIZED(PyObject *op) {
PyGC_Head *gc = _Py_AS_GC(op);
_PyGCHead_SET_FINALIZED(gc);
}
static inline void _PyGC_CLEAR_FINALIZED(PyObject *op) {
PyGC_Head *gc = _Py_AS_GC(op);
gc->_gc_prev &= ~_PyGC_PREV_MASK_FINALIZED;
}


/* GC runtime state */
Expand Down
2 changes: 2 additions & 0 deletions Objects/genobject.c
Expand Up @@ -6,6 +6,7 @@
#include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_ceval.h" // _PyEval_EvalFrame()
#include "pycore_frame.h" // _PyInterpreterFrame
#include "pycore_gc.h" // _PyGC_CLEAR_FINALIZED()
#include "pycore_genobject.h" // struct _Py_async_gen_state
#include "pycore_modsupport.h" // _PyArg_CheckPositional()
#include "pycore_object.h" // _PyObject_GC_UNTRACK()
Expand Down Expand Up @@ -1913,6 +1914,7 @@ async_gen_asend_new(PyAsyncGenObject *gen, PyObject *sendval)
if (state->asend_numfree) {
state->asend_numfree--;
o = state->asend_freelist[state->asend_numfree];
_PyGC_CLEAR_FINALIZED((PyObject *)o);
_Py_NewReference((PyObject *)o);
}
else
Expand Down

0 comments on commit 7ae71e9

Please sign in to comment.