Skip to content

Commit 8590127

Browse files
maurycymiss-islington
authored andcommitted
gh-151424: Fix impossible stack traces in RemoteUnwinder(..., cache_frames=True) by copying chunks on cache miss (GH-151426)
(cherry picked from commit 6ce088e) Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
1 parent 5dd3217 commit 8590127

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fix impossible stack traces (callers and callees cross called, orphans and
2+
incorrect lines) in the Tachyon profiler when caching frames, by snapshotting
3+
the stack chunks before walking the frame chain on a cache miss. Patch by
4+
Maurycy Pawłowski-Wieroński.

Modules/_remote_debugging/frames.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,14 @@ collect_frames_with_cache(
580580
return full_hit < 0 ? -1 : 0;
581581
}
582582

583+
assert(ctx->chunks != NULL);
584+
585+
if (ctx->chunks->count == 0) {
586+
if (copy_stack_chunks(unwinder, ctx->thread_state_addr, ctx->chunks) < 0) {
587+
PyErr_Clear();
588+
}
589+
}
590+
583591
Py_ssize_t frames_before = PyList_GET_SIZE(ctx->frame_info);
584592

585593
if (process_frame_chain(unwinder, ctx) < 0) {

0 commit comments

Comments
 (0)