aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/traceback.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-11-27 16:14:49 +0100
committerGitHub <noreply@github.com>2024-11-27 16:14:49 +0100
commit58e334e1431b2ed6b70ee42501ea73e08084e769 (patch)
treed3075caece78b955d82b5ffd152c5405788c819a /Python/traceback.c
parent9328db7652677a23192cb51b0324a0fdbfa587c9 (diff)
downloadcpython-58e334e1431b2ed6b70ee42501ea73e08084e769.tar.gz
cpython-58e334e1431b2ed6b70ee42501ea73e08084e769.zip
gh-123967: Fix faulthandler for trampoline frames (#127329)
If the top-most frame is a trampoline frame, skip it.
Diffstat (limited to 'Python/traceback.c')
-rw-r--r--Python/traceback.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/Python/traceback.c b/Python/traceback.c
index 47b77c9108d..e819909b604 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -890,6 +890,8 @@ done:
static void
dump_frame(int fd, _PyInterpreterFrame *frame)
{
+ assert(frame->owner != FRAME_OWNED_BY_CSTACK);
+
PyCodeObject *code =_PyFrame_GetCode(frame);
PUTS(fd, " File ");
if (code->co_filename != NULL
@@ -963,6 +965,17 @@ dump_traceback(int fd, PyThreadState *tstate, int write_header)
unsigned int depth = 0;
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) {
PUTS(fd, "plus ");
@@ -971,20 +984,12 @@ dump_traceback(int fd, PyThreadState *tstate, int write_header)
}
break;
}
+
dump_frame(fd, frame);
frame = frame->previous;
if (frame == NULL) {
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++;
}
}