Repository navigation
Commit c41fa1f
committed
gh-154130: Fix double decref of the dict in shared dict iterators
In the free-threaded build, threads advancing the same dict iterator each
read `di_dict` as a borrowed reference, so concurrently exhausting it could run
`di->di_dict = NULL; Py_DECREF(d)` more than once and free the dict while
other threads were still using it. Reversed iterators were also affected:
they dropped the reference while holding the dict's critical section.
In the free-threaded build, keep the iterator's reference to the dict until
the iterator is deallocated (as list and tuple iterators do) and mark
exhaustion by setting `di_pos` to -1.1 parent f65e2a2 commit c41fa1f
2 files changed
Lines changed: 72 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
493 | 493 | | |
494 | 494 | | |
495 | 495 | | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
496 | 533 | | |
497 | 534 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5705 | 5705 | | |
5706 | 5706 | | |
5707 | 5707 | | |
| 5708 | + | |
| 5709 | + | |
| 5710 | + | |
| 5711 | + | |
| 5712 | + | |
| 5713 | + | |
| 5714 | + | |
| 5715 | + | |
| 5716 | + | |
| 5717 | + | |
| 5718 | + | |
| 5719 | + | |
| 5720 | + | |
| 5721 | + | |
| 5722 | + | |
| 5723 | + | |
| 5724 | + | |
5708 | 5725 | | |
5709 | 5726 | | |
5710 | 5727 | | |
| |||
5970 | 5987 | | |
5971 | 5988 | | |
5972 | 5989 | | |
| 5990 | + | |
| 5991 | + | |
| 5992 | + | |
| 5993 | + | |
| 5994 | + | |
5973 | 5995 | | |
5974 | 5996 | | |
5975 | 5997 | | |
5976 | 5998 | | |
5977 | 5999 | | |
5978 | 6000 | | |
5979 | 6001 | | |
5980 | | - | |
5981 | | - | |
5982 | | - | |
5983 | 6002 | | |
5984 | 6003 | | |
5985 | 6004 | | |
| |||
6030 | 6049 | | |
6031 | 6050 | | |
6032 | 6051 | | |
6033 | | - | |
6034 | | - | |
| 6052 | + | |
6035 | 6053 | | |
6036 | 6054 | | |
6037 | 6055 | | |
| |||
6075 | 6093 | | |
6076 | 6094 | | |
6077 | 6095 | | |
| 6096 | + | |
| 6097 | + | |
| 6098 | + | |
| 6099 | + | |
| 6100 | + | |
6078 | 6101 | | |
6079 | 6102 | | |
6080 | 6103 | | |
| |||
6084 | 6107 | | |
6085 | 6108 | | |
6086 | 6109 | | |
6087 | | - | |
6088 | 6110 | | |
6089 | | - | |
6090 | 6111 | | |
6091 | 6112 | | |
6092 | 6113 | | |
| |||
6165 | 6186 | | |
6166 | 6187 | | |
6167 | 6188 | | |
6168 | | - | |
6169 | | - | |
| 6189 | + | |
6170 | 6190 | | |
6171 | 6191 | | |
6172 | 6192 | | |
| |||
6354 | 6374 | | |
6355 | 6375 | | |
6356 | 6376 | | |
6357 | | - | |
6358 | | - | |
| 6377 | + | |
6359 | 6378 | | |
6360 | 6379 | | |
6361 | 6380 | | |
| |||
6367 | 6386 | | |
6368 | 6387 | | |
6369 | 6388 | | |
| 6389 | + | |
| 6390 | + | |
| 6391 | + | |
| 6392 | + | |
| 6393 | + | |
6370 | 6394 | | |
6371 | 6395 | | |
6372 | 6396 | | |
| |||
0 commit comments