diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2023-01-09 20:20:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-09 20:20:04 (GMT) |
commit | 61762b93871419b34f02d83cee5ca0d94d4a2903 (patch) | |
tree | 286b9aff961b5435e2d34894857a603ae86aa5c6 /Modules | |
parent | 2e80c2a976c13dcb69a654b386164dca362295a3 (diff) | |
download | cpython-61762b93871419b34f02d83cee5ca0d94d4a2903.zip cpython-61762b93871419b34f02d83cee5ca0d94d4a2903.tar.gz cpython-61762b93871419b34f02d83cee5ca0d94d4a2903.tar.bz2 |
GH-100126: Skip incomplete frames in more places (GH-100613)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_tracemalloc.c | 13 | ||||
-rw-r--r-- | Modules/signalmodule.c | 5 |
2 files changed, 4 insertions, 14 deletions
diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c index ac16626..9826ad2 100644 --- a/Modules/_tracemalloc.c +++ b/Modules/_tracemalloc.c @@ -347,14 +347,8 @@ traceback_get_frames(traceback_t *traceback) return; } - _PyInterpreterFrame *pyframe = tstate->cframe->current_frame; - for (;;) { - while (pyframe && _PyFrame_IsIncomplete(pyframe)) { - pyframe = pyframe->previous; - } - if (pyframe == NULL) { - break; - } + _PyInterpreterFrame *pyframe = _PyThreadState_GetFrame(tstate); + while (pyframe) { if (traceback->nframe < tracemalloc_config.max_nframe) { tracemalloc_get_frame(pyframe, &traceback->frames[traceback->nframe]); assert(traceback->frames[traceback->nframe].filename != NULL); @@ -363,8 +357,7 @@ traceback_get_frames(traceback_t *traceback) if (traceback->total_nframe < UINT16_MAX) { traceback->total_nframe++; } - - pyframe = pyframe->previous; + pyframe = _PyFrame_GetFirstComplete(pyframe->previous); } } diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index 538a7e8..44a5ecf 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -1803,10 +1803,7 @@ _PyErr_CheckSignalsTstate(PyThreadState *tstate) */ _Py_atomic_store(&is_tripped, 0); - _PyInterpreterFrame *frame = tstate->cframe->current_frame; - while (frame && _PyFrame_IsIncomplete(frame)) { - frame = frame->previous; - } + _PyInterpreterFrame *frame = _PyThreadState_GetFrame(tstate); signal_state_t *state = &signal_global_state; for (int i = 1; i < Py_NSIG; i++) { if (!_Py_atomic_load_relaxed(&Handlers[i].tripped)) { |