diff options
Diffstat (limited to 'Objects/frameobject.c')
-rw-r--r-- | Objects/frameobject.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c index 0fe9f2a666..0dad42ee7b 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -595,6 +595,10 @@ frame_dealloc(PyFrameObject *f) else { PyInterpreterState *interp = _PyInterpreterState_GET(); struct _Py_frame_state *state = &interp->frame; +#ifdef Py_DEBUG + // frame_dealloc() must not be called after _PyFrame_Fini() + assert(state->numfree != -1); +#endif if (state->numfree < PyFrame_MAXFREELIST) { ++state->numfree; f->f_back = state->free_list; @@ -790,6 +794,10 @@ frame_alloc(PyCodeObject *code) } } else { +#ifdef Py_DEBUG + // frame_alloc() must not be called after _PyFrame_Fini() + assert(state->numfree != -1); +#endif assert(state->numfree > 0); --state->numfree; f = state->free_list; @@ -1188,6 +1196,10 @@ void _PyFrame_Fini(PyThreadState *tstate) { _PyFrame_ClearFreeList(tstate); +#ifdef Py_DEBUG + struct _Py_frame_state *state = &tstate->interp->frame; + state->numfree = -1; +#endif } /* Print summary info about the state of the optimized allocator */ |