diff options
author | Mark Shannon <mark@hotpy.org> | 2022-09-06 17:42:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-06 17:42:41 (GMT) |
commit | 26dc4dfac31cf657bf6deb5aaab2df5b9b7c1a74 (patch) | |
tree | c53acadee1b599691823bb196b6e43fadb2ec1c8 /Modules | |
parent | a0848d169b6982394c539deead0de18f251dfc6d (diff) | |
download | cpython-26dc4dfac31cf657bf6deb5aaab2df5b9b7c1a74.zip cpython-26dc4dfac31cf657bf6deb5aaab2df5b9b7c1a74.tar.gz cpython-26dc4dfac31cf657bf6deb5aaab2df5b9b7c1a74.tar.bz2 |
[3.11] GH-96612: Skip incomplete frames in tracemalloc traces. (GH-96613) (#96617)
(cherry picked from commit 95e271b2266b8f2e7b60ede86ccf3ede4a7f83eb)
Co-authored-by: Mark Shannon <mark@hotpy.org>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_tracemalloc.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c index ae09869..44a1f7b 100644 --- a/Modules/_tracemalloc.c +++ b/Modules/_tracemalloc.c @@ -400,7 +400,13 @@ traceback_get_frames(traceback_t *traceback) } _PyInterpreterFrame *pyframe = tstate->cframe->current_frame; - for (; pyframe != NULL;) { + for (;;) { + while (pyframe && _PyFrame_IsIncomplete(pyframe)) { + pyframe = pyframe->previous; + } + if (pyframe == NULL) { + break; + } if (traceback->nframe < _Py_tracemalloc_config.max_nframe) { tracemalloc_get_frame(pyframe, &traceback->frames[traceback->nframe]); assert(traceback->frames[traceback->nframe].filename != NULL); @@ -410,8 +416,7 @@ traceback_get_frames(traceback_t *traceback) traceback->total_nframe++; } - _PyInterpreterFrame *back = pyframe->previous; - pyframe = back; + pyframe = pyframe->previous; } } |