Commit af0c252
authored
Fix GC TOCTOU race in collect_inner referent traversal (RustPython#7511)
Pre-compute referent pointers once per object in step 3 and reuse
them in step 4 (BFS reachability). Previously, gc_get_referent_ptrs()
was called independently in both steps. If a dict's write lock state
changed between the two calls (e.g., held by another thread during
one traversal but not the other), the two traversals could return
different results. This caused live objects to be incorrectly
classified as unreachable and cleared by GC.1 parent f42ffd6 commit af0c252
1 file changed
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
460 | 467 | | |
461 | 468 | | |
462 | 469 | | |
463 | 470 | | |
464 | 471 | | |
465 | 472 | | |
| 473 | + | |
466 | 474 | | |
467 | 475 | | |
468 | 476 | | |
| |||
487 | 495 | | |
488 | 496 | | |
489 | 497 | | |
490 | | - | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
491 | 505 | | |
492 | 506 | | |
493 | 507 | | |
| |||
0 commit comments