mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
gh-123967: Fix faulthandler for trampoline frames (#127329)
If the top-most frame is a trampoline frame, skip it.
This commit is contained in:
parent
9328db7652
commit
58e334e143
2 changed files with 16 additions and 9 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
Fix faulthandler for trampoline frames. If the top-most frame is a
|
||||||
|
trampoline frame, skip it. Patch by Victor Stinner.
|
|
@ -890,6 +890,8 @@ done:
|
||||||
static void
|
static void
|
||||||
dump_frame(int fd, _PyInterpreterFrame *frame)
|
dump_frame(int fd, _PyInterpreterFrame *frame)
|
||||||
{
|
{
|
||||||
|
assert(frame->owner != FRAME_OWNED_BY_CSTACK);
|
||||||
|
|
||||||
PyCodeObject *code =_PyFrame_GetCode(frame);
|
PyCodeObject *code =_PyFrame_GetCode(frame);
|
||||||
PUTS(fd, " File ");
|
PUTS(fd, " File ");
|
||||||
if (code->co_filename != NULL
|
if (code->co_filename != NULL
|
||||||
|
@ -963,6 +965,17 @@ dump_traceback(int fd, PyThreadState *tstate, int write_header)
|
||||||
|
|
||||||
unsigned int depth = 0;
|
unsigned int depth = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
|
if (frame->owner == FRAME_OWNED_BY_CSTACK) {
|
||||||
|
/* Trampoline frame */
|
||||||
|
frame = frame->previous;
|
||||||
|
if (frame == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Can't have more than one shim frame in a row */
|
||||||
|
assert(frame->owner != FRAME_OWNED_BY_CSTACK);
|
||||||
|
}
|
||||||
|
|
||||||
if (MAX_FRAME_DEPTH <= depth) {
|
if (MAX_FRAME_DEPTH <= depth) {
|
||||||
if (MAX_FRAME_DEPTH < depth) {
|
if (MAX_FRAME_DEPTH < depth) {
|
||||||
PUTS(fd, "plus ");
|
PUTS(fd, "plus ");
|
||||||
|
@ -971,20 +984,12 @@ dump_traceback(int fd, PyThreadState *tstate, int write_header)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dump_frame(fd, frame);
|
dump_frame(fd, frame);
|
||||||
frame = frame->previous;
|
frame = frame->previous;
|
||||||
if (frame == NULL) {
|
if (frame == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (frame->owner == FRAME_OWNED_BY_CSTACK) {
|
|
||||||
/* Trampoline frame */
|
|
||||||
frame = frame->previous;
|
|
||||||
}
|
|
||||||
if (frame == NULL) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* Can't have more than one shim frame in a row */
|
|
||||||
assert(frame->owner != FRAME_OWNED_BY_CSTACK);
|
|
||||||
depth++;
|
depth++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue