GH-96612: Skip incomplete frames in tracemalloc traces. (GH-96613)

This commit is contained in:
Mark Shannon 2022-09-06 17:37:47 +01:00 • committed by GitHub
parent f0d9136c69
commit 95e271b226
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 3 deletions

View file

@ -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;
}
}