Commit 38c4fce
committed
[Concurrency] Fix a race when using cancelAll on a task group concurrently with child tasks being removed.
_swift_taskGroup_cancelAllChildren relies on there being no concurrent modification when called from the owning task, but this is not guaranteed.
Rearrange things to always take the owning task's status record lock when walking the group's children. Split _swift_taskGroup_cancelAllChildren into two functions, one which assumes/requires the lock is already held, and one which acquires the lock. We don't have the owning task in this case, but we can either get it from the current task, or by looking at the parent of the child task we're working on.
rdar://1471729911 parent 3a4549b commit 38c4fce
File tree
4 files changed
+66
-36
lines changed- include/swift/ABI
- stdlib/public/Concurrency
4 files changed
+66
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
137 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
138 | 140 | | |
139 | 141 | | |
| 142 | + | |
140 | 143 | | |
141 | 144 | | |
142 | 145 | | |
| |||
155 | 158 | | |
156 | 159 | | |
157 | 160 | | |
158 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
159 | 164 | | |
160 | 165 | | |
161 | 166 | | |
| |||
165 | 170 | | |
166 | 171 | | |
167 | 172 | | |
168 | | - | |
| 173 | + | |
169 | 174 | | |
170 | | - | |
| 175 | + | |
171 | 176 | | |
172 | 177 | | |
173 | 178 | | |
| |||
176 | 181 | | |
177 | 182 | | |
178 | 183 | | |
179 | | - | |
180 | | - | |
181 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
182 | 191 | | |
183 | 192 | | |
184 | 193 | | |
185 | 194 | | |
186 | 195 | | |
187 | | - | |
188 | 196 | | |
189 | 197 | | |
190 | 198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
477 | | - | |
478 | | - | |
479 | | - | |
| 477 | + | |
| 478 | + | |
480 | 479 | | |
481 | 480 | | |
482 | 481 | | |
| |||
1378 | 1377 | | |
1379 | 1378 | | |
1380 | 1379 | | |
1381 | | - | |
| 1380 | + | |
| 1381 | + | |
1382 | 1382 | | |
1383 | 1383 | | |
1384 | 1384 | | |
| |||
2097 | 2097 | | |
2098 | 2098 | | |
2099 | 2099 | | |
2100 | | - | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
2101 | 2103 | | |
2102 | 2104 | | |
2103 | | - | |
| 2105 | + | |
2104 | 2106 | | |
2105 | 2107 | | |
2106 | 2108 | | |
| |||
2114 | 2116 | | |
2115 | 2117 | | |
2116 | 2118 | | |
2117 | | - | |
2118 | | - | |
| 2119 | + | |
| 2120 | + | |
2119 | 2121 | | |
2120 | 2122 | | |
2121 | 2123 | | |
| |||
2124 | 2126 | | |
2125 | 2127 | | |
2126 | 2128 | | |
2127 | | - | |
2128 | | - | |
2129 | | - | |
2130 | | - | |
2131 | | - | |
2132 | | - | |
2133 | | - | |
2134 | | - | |
2135 | | - | |
2136 | | - | |
2137 | | - | |
2138 | | - | |
2139 | | - | |
2140 | | - | |
2141 | | - | |
2142 | | - | |
| 2129 | + | |
| 2130 | + | |
2143 | 2131 | | |
2144 | 2132 | | |
2145 | 2133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
94 | | - | |
95 | | - | |
| 93 | + | |
| 94 | + | |
96 | 95 | | |
97 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
98 | 103 | | |
99 | 104 | | |
100 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
943 | 943 | | |
944 | 944 | | |
945 | 945 | | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
946 | 975 | | |
947 | 976 | | |
948 | 977 | | |
| |||
0 commit comments