Commit 66ade28
gh-146452: Improve locking granularity in pickle's batch_dict_exact and fix race condition (GH-150025)
Remove assertion that could fail in rare race condition.
Replace the coarse critical section wrapping the entire function with
fine-grained sections covering only PyDict_Next + Py_INCREF.
Also handle PyDict_Next returning 0 in the single-item fast path.
(cherry picked from commit 57a0e57)
Co-authored-by: Saul Cooperman <58375603+scopreon@users.noreply.github.com>
1 parent c417fca commit 66ade28
2 files changed
Lines changed: 30 additions & 7 deletions
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3450 | 3450 | | |
3451 | 3451 | | |
3452 | 3452 | | |
| 3453 | + | |
| 3454 | + | |
| 3455 | + | |
3453 | 3456 | | |
3454 | 3457 | | |
3455 | 3458 | | |
| |||
3466 | 3469 | | |
3467 | 3470 | | |
3468 | 3471 | | |
3469 | | - | |
3470 | 3472 | | |
3471 | 3473 | | |
3472 | 3474 | | |
3473 | 3475 | | |
3474 | 3476 | | |
3475 | | - | |
3476 | | - | |
3477 | | - | |
| 3477 | + | |
| 3478 | + | |
| 3479 | + | |
| 3480 | + | |
| 3481 | + | |
| 3482 | + | |
| 3483 | + | |
| 3484 | + | |
| 3485 | + | |
| 3486 | + | |
| 3487 | + | |
| 3488 | + | |
| 3489 | + | |
3478 | 3490 | | |
3479 | 3491 | | |
3480 | 3492 | | |
| |||
3492 | 3504 | | |
3493 | 3505 | | |
3494 | 3506 | | |
3495 | | - | |
3496 | | - | |
3497 | | - | |
| 3507 | + | |
| 3508 | + | |
| 3509 | + | |
| 3510 | + | |
| 3511 | + | |
| 3512 | + | |
| 3513 | + | |
| 3514 | + | |
| 3515 | + | |
| 3516 | + | |
| 3517 | + | |
| 3518 | + | |
3498 | 3519 | | |
3499 | 3520 | | |
3500 | 3521 | | |
| |||
0 commit comments