summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS.d/next/Library/2024-11-27-14-06-35.gh-issue-123967.wxUmnW.rst2
-rw-r--r--Python/traceback.c23
2 files changed, 16 insertions, 9 deletions
diff --git a/Misc/NEWS.d/next/Library/2024-11-27-14-06-35.gh-issue-123967.wxUmnW.rst b/Misc/NEWS.d/next/Library/2024-11-27-14-06-35.gh-issue-123967.wxUmnW.rst
new file mode 100644
index 0000000..788fe0c
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-11-27-14-06-35.gh-issue-123967.wxUmnW.rst
@@ -0,0 +1,2 @@
+Fix faulthandler for trampoline frames. If the top-most frame is a
+trampoline frame, skip it. Patch by Victor Stinner.
diff --git a/Python/traceback.c b/Python/traceback.c
index 47b77c9..e819909 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++;
}
}