]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-151613: Fix remote debugging frame cache ABA (#151614)
authorPablo Galindo Salgado <Pablogsal@gmail.com>
Sat, 27 Jun 2026 16:56:31 +0000 (18:56 +0200)
committerGitHub <noreply@github.com>
Sat, 27 Jun 2026 16:56:31 +0000 (16:56 +0000)
commit8cda6ae2f1f86f2d26c29586ffc9687b410abfcf
tree465a072bf15069dccea96c9213a34a6fae46f56a
parent876c06cab9e824747d708a031c6b81b1f8a4f8dc
gh-151613: Fix remote debugging frame cache ABA (#151614)

The remote debugging frame cache previously used only the last_profiled_frame address as its cache anchor. If a frame returned and a later frame reused the same _PyInterpreterFrame address, the profiler could accept a stale cache entry and splice parent frames from a different call chain into the current stack.

This adds a last_profiled_frame_seq counter next to last_profiled_frame, increments it when the anchor advances, stores it in frame cache entries, and validates cache hits against both the frame address and the sequence. Cache miss walks now copy stack chunks before storing new cache entries so stored continuations come from a stable snapshot. The new regression test exercises alternating call chains and checks that cached stacks never contain frames from both branches.
13 files changed:
Include/cpython/pystate.h
Include/internal/pycore_debug_offsets.h
Include/internal/pycore_interpframe.h
InternalDocs/frames.md
Misc/NEWS.d/next/Library/2026-06-13-11-57-48.gh-issue-151436.UEDowO.rst
Misc/NEWS.d/next/Library/2026-06-17-22-31-57.gh-issue-151613.n0nua1.rst [new file with mode: 0644]
Modules/_remote_debugging/_remote_debugging.h
Modules/_remote_debugging/debug_offsets_validation.h
Modules/_remote_debugging/frame_cache.c
Modules/_remote_debugging/frames.c
Modules/_remote_debugging/module.c
Modules/_remote_debugging/threads.c
Python/pystate.c