]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-151424: Fix impossible stack traces in `RemoteUnwinder(..., cache_frames=True... main
authorMaurycy Pawłowski-Wieroński <maurycy@maurycy.com>
Sat, 13 Jun 2026 23:10:56 +0000 (01:10 +0200)
committerGitHub <noreply@github.com>
Sat, 13 Jun 2026 23:10:56 +0000 (00:10 +0100)
Misc/NEWS.d/next/Library/2026-06-13-04-11-00.gh-issue-151426.f2V67e.rst [new file with mode: 0644]
Modules/_remote_debugging/frames.c

diff --git a/Misc/NEWS.d/next/Library/2026-06-13-04-11-00.gh-issue-151426.f2V67e.rst b/Misc/NEWS.d/next/Library/2026-06-13-04-11-00.gh-issue-151426.f2V67e.rst
new file mode 100644 (file)
index 0000000..428302e
--- /dev/null
@@ -0,0 +1,4 @@
+Fix impossible stack traces (callers and callees cross called, orphans and
+incorrect lines) in the Tachyon profiler when caching frames, by snapshotting
+the stack chunks before walking the frame chain on a cache miss. Patch by
+Maurycy Pawłowski-Wieroński.
index d73cd080dc477f3adbf32a084bcd5df471b4b347..e7d2a27643902615366a450e7be30dc829daf946 100644 (file)
@@ -580,6 +580,14 @@ collect_frames_with_cache(
         return full_hit < 0 ? -1 : 0;
     }
 
+    assert(ctx->chunks != NULL);
+
+    if (ctx->chunks->count == 0) {
+        if (copy_stack_chunks(unwinder, ctx->thread_state_addr, ctx->chunks) < 0) {
+            PyErr_Clear();
+        }
+    }
+
     Py_ssize_t frames_before = PyList_GET_SIZE(ctx->frame_info);
 
     if (process_frame_chain(unwinder, ctx) < 0) {