mirror of
https://github.com/python/cpython.git
synced 2026-06-27 19:36:07 +00:00
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.
(cherry picked from commit
|
||
|---|---|---|
| .. | ||
| images | ||
| asyncio.md | ||
| changing_grammar.md | ||
| code_objects.md | ||
| compiler.md | ||
| exception_handling.md | ||
| frames.md | ||
| garbage_collector.md | ||
| generators.md | ||
| interpreter.md | ||
| jit.md | ||
| parser.md | ||
| profiling_binary_format.md | ||
| qsbr.md | ||
| README.md | ||
| stack_protection.md | ||
| stackrefs.md | ||
| string_interning.md | ||
| structure.md | ||
CPython Internals Documentation
The documentation in this folder is intended for CPython maintainers. It describes implementation details of CPython, which should not be assumed to be part of the Python language specification. These details can change between any two CPython versions and should not be assumed to hold for other implementations of the Python language.
The core dev team attempts to keep this documentation up to date. If it is not, please report that through the issue tracker.