Skip to content

[3.15] gh-151613: Fix remote debugging frame cache ABA#152448

Merged
pablogsal merged 1 commit into
python:3.15from
pablogsal:backport-8cda6ae-3.15
Jun 27, 2026
Merged

[3.15] gh-151613: Fix remote debugging frame cache ABA#152448
pablogsal merged 1 commit into
python:3.15from
pablogsal:backport-8cda6ae-3.15

Conversation

@pablogsal

@pablogsal pablogsal commented Jun 27, 2026

Copy link
Copy Markdown
Member

Backport of gh-151613 to Python 3.15.

Original commit: 8cda6ae
Original PR: GH-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.

(cherry picked from commit 8cda6ae)
@pablogsal pablogsal marked this pull request as ready for review June 27, 2026 17:15
@pablogsal pablogsal enabled auto-merge (squash) June 27, 2026 17:15
@pablogsal pablogsal merged commit 65fbec6 into python:3.15 Jun 27, 2026
55 checks passed
@pablogsal pablogsal deleted the backport-8cda6ae-3.15 branch June 27, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant