gh-151424: Fix impossible stack traces in `RemoteUnwinder(..., cache_frames=True)` by copying chunks on cache miss (GH-151426)
(cherry picked from commit
6ce088e20a13ac25320d94c5775bb1a4edc75ba4)
Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
--- /dev/null
+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.
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) {