Commit a548b24
committed
gh-151613: Fix remote debugging frame cache ABA
Fixes #151613.
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.1 parent a8d74c0 commit a548b24Copy full SHA for a548b24
12 files changed
+218-14Lines changed: 218 additions & 14 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- Include
- cpython
- internal
- Lib/test
- Misc/NEWS.d/next/Library
- Modules/_remote_debugging
- Python
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+1Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
143 | 143 | |
144 | 144 | |
145 | 145 | |
| 146 | + |
146 | 147 | |
147 | 148 | |
148 | 149 | |
|
Collapse file
Include/internal/pycore_debug_offsets.h
Copy file name to clipboardExpand all lines: Include/internal/pycore_debug_offsets.h+2Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
104 | 104 | |
105 | 105 | |
106 | 106 | |
| 107 | + |
107 | 108 | |
108 | 109 | |
109 | 110 | |
| ||
294 | 295 | |
295 | 296 | |
296 | 297 | |
| 298 | + |
297 | 299 | |
298 | 300 | |
299 | 301 | |
|
Collapse file
Include/internal/pycore_interpframe.h
Copy file name to clipboardExpand all lines: Include/internal/pycore_interpframe.h+3Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
292 | 292 | |
293 | 293 | |
294 | 294 | |
| 295 | + |
| 296 | + |
295 | 297 | |
296 | 298 | |
297 | 299 | |
298 | 300 | |
299 | 301 | |
300 | 302 | |
| 303 | + |
301 | 304 | |
302 | 305 | |
303 | 306 | |
|
Collapse file
Lib/test/test_external_inspection.py
Copy file name to clipboardExpand all lines: Lib/test/test_external_inspection.py+82Lines changed: 82 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
3451 | 3451 | |
3452 | 3452 | |
3453 | 3453 | |
| 3454 | + |
| 3455 | + |
| 3456 | + |
| 3457 | + |
| 3458 | + |
| 3459 | + |
| 3460 | + |
| 3461 | + |
| 3462 | + |
| 3463 | + |
| 3464 | + |
| 3465 | + |
| 3466 | + |
| 3467 | + |
| 3468 | + |
| 3469 | + |
| 3470 | + |
| 3471 | + |
| 3472 | + |
| 3473 | + |
| 3474 | + |
| 3475 | + |
| 3476 | + |
| 3477 | + |
| 3478 | + |
| 3479 | + |
| 3480 | + |
| 3481 | + |
| 3482 | + |
| 3483 | + |
| 3484 | + |
| 3485 | + |
| 3486 | + |
| 3487 | + |
| 3488 | + |
| 3489 | + |
| 3490 | + |
| 3491 | + |
| 3492 | + |
| 3493 | + |
| 3494 | + |
| 3495 | + |
| 3496 | + |
| 3497 | + |
| 3498 | + |
| 3499 | + |
| 3500 | + |
| 3501 | + |
| 3502 | + |
| 3503 | + |
| 3504 | + |
| 3505 | + |
| 3506 | + |
| 3507 | + |
| 3508 | + |
| 3509 | + |
| 3510 | + |
| 3511 | + |
| 3512 | + |
| 3513 | + |
| 3514 | + |
| 3515 | + |
| 3516 | + |
| 3517 | + |
| 3518 | + |
| 3519 | + |
| 3520 | + |
| 3521 | + |
| 3522 | + |
| 3523 | + |
| 3524 | + |
| 3525 | + |
| 3526 | + |
| 3527 | + |
| 3528 | + |
| 3529 | + |
| 3530 | + |
| 3531 | + |
| 3532 | + |
| 3533 | + |
| 3534 | + |
| 3535 | + |
3454 | 3536 | |
3455 | 3537 | |
3456 | 3538 | |
|
Collapse file
Misc/NEWS.d/next/Library/2026-06-13-11-57-48.gh-issue-151436.UEDowO.rst
Copy file name to clipboard+1-1Lines changed: 1 addition & 1 deletion
- Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1 | | - |
| 1 | + |
2 | 2 | |
3 | 3 | |
4 | 4 | |
Collapse file
Misc/NEWS.d/next/Library/2026-06-17-22-31-57.gh-issue-151613.n0nua1.rst
Copy file name to clipboard+3Lines changed: 3 additions & 0 deletions
- Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
Collapse file
Modules/_remote_debugging/_remote_debugging.h
Copy file name to clipboardExpand all lines: Modules/_remote_debugging/_remote_debugging.h+10Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
228 | 228 | |
229 | 229 | |
230 | 230 | |
| 231 | + |
231 | 232 | |
232 | 233 | |
233 | 234 | |
| ||
435 | 436 | |
436 | 437 | |
437 | 438 | |
| 439 | + |
438 | 440 | |
439 | 441 | |
440 | 442 | |
| ||
626 | 628 | |
627 | 629 | |
628 | 630 | |
| 631 | + |
629 | 632 | |
| 633 | + |
630 | 634 | |
631 | 635 | |
632 | 636 | |
633 | 637 | |
| 638 | + |
| 639 | + |
| 640 | + |
| 641 | + |
| 642 | + |
634 | 643 | |
635 | 644 | |
636 | 645 | |
| ||
640 | 649 | |
641 | 650 | |
642 | 651 | |
| 652 | + |
643 | 653 | |
644 | 654 | |
645 | 655 | |
|
Collapse file
Modules/_remote_debugging/debug_offsets_validation.h
Copy file name to clipboardExpand all lines: Modules/_remote_debugging/debug_offsets_validation.h+3-2Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | | - |
| 34 | + |
35 | 35 | |
36 | 36 | |
37 | 37 | |
| ||
261 | 261 | |
262 | 262 | |
263 | 263 | |
264 | | - |
| 264 | + |
| 265 | + |
265 | 266 | |
266 | 267 | |
267 | 268 | |
|
Collapse file
Modules/_remote_debugging/frame_cache.c
Copy file name to clipboardExpand all lines: Modules/_remote_debugging/frame_cache.c+66Lines changed: 66 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
147 | 147 | |
148 | 148 | |
149 | 149 | |
| 150 | + |
150 | 151 | |
151 | 152 | |
152 | 153 | |
153 | 154 | |
154 | 155 | |
155 | 156 | |
| 157 | + |
| 158 | + |
| 159 | + |
| 160 | + |
| 161 | + |
| 162 | + |
| 163 | + |
| 164 | + |
| 165 | + |
| 166 | + |
| 167 | + |
| 168 | + |
| 169 | + |
| 170 | + |
| 171 | + |
| 172 | + |
| 173 | + |
| 174 | + |
| 175 | + |
| 176 | + |
| 177 | + |
| 178 | + |
| 179 | + |
| 180 | + |
| 181 | + |
| 182 | + |
| 183 | + |
| 184 | + |
| 185 | + |
| 186 | + |
| 187 | + |
| 188 | + |
| 189 | + |
| 190 | + |
| 191 | + |
| 192 | + |
| 193 | + |
156 | 194 | |
157 | 195 | |
158 | 196 | |
159 | 197 | |
160 | 198 | |
161 | 199 | |
| 200 | + |
162 | 201 | |
| 202 | + |
163 | 203 | |
164 | 204 | |
165 | 205 | |
| ||
173 | 213 | |
174 | 214 | |
175 | 215 | |
| 216 | + |
| 217 | + |
| 218 | + |
176 | 219 | |
177 | 220 | |
178 | 221 | |
| ||
189 | 232 | |
190 | 233 | |
191 | 234 | |
| 235 | + |
| 236 | + |
| 237 | + |
| 238 | + |
| 239 | + |
| 240 | + |
| 241 | + |
| 242 | + |
| 243 | + |
| 244 | + |
| 245 | + |
| 246 | + |
| 247 | + |
192 | 248 | |
193 | 249 | |
| 250 | + |
| 251 | + |
| 252 | + |
194 | 253 | |
195 | 254 | |
196 | 255 | |
| ||
200 | 259 | |
201 | 260 | |
202 | 261 | |
| 262 | + |
| 263 | + |
| 264 | + |
| 265 | + |
| 266 | + |
203 | 267 | |
204 | 268 | |
205 | 269 | |
| ||
235 | 299 | |
236 | 300 | |
237 | 301 | |
| 302 | + |
238 | 303 | |
239 | 304 | |
240 | 305 | |
| ||
277 | 342 | |
278 | 343 | |
279 | 344 | |
| 345 | + |
280 | 346 | |
281 | 347 | |
282 | 348 | |
|
0 commit comments