Commit a9cd1ff
committed
gh-154916: Fix data race in ga_iter_reduce under free-threading
ga_iternext takes gi->obj out with an atomic exchange and then drops the
reference, while ga_iter_reduce read the same field twice without
synchronisation. The two reads can straddle the exchange, so the guard
can observe a non-NULL pointer that is then passed to Py_BuildValue after
the owning thread has already released it.
Take a single strong reference instead, and mark the stored object as
maybe-weakref in ga_iter, which _Py_XGetRef requires of the writer.1 parent 405daf5 commit a9cd1ff
2 files changed
Lines changed: 21 additions & 2 deletions
File tree
- Misc/NEWS.d/next/Core_and_Builtins
- Objects
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
997 | 997 | | |
998 | 998 | | |
999 | 999 | | |
1000 | | - | |
1001 | | - | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
1002 | 1013 | | |
1003 | 1014 | | |
1004 | 1015 | | |
| |||
1030 | 1041 | | |
1031 | 1042 | | |
1032 | 1043 | | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
1033 | 1049 | | |
1034 | 1050 | | |
1035 | 1051 | | |
| |||
0 commit comments