Commit d108713
authored
[RuntimeAsync] Do not hold on to the last used Continuation in the runtime async tasks. (#121460)
Fixes: #121459
The wrapped continuation is expected to be used only once - when the
corresponding async method is resumed. We can and should null-out the
continuation while fetching it in the dispatcher. There is no need to
keep it referenced from the task once fetched as it may cause "leaks"
observable via WeakReference/Finalization and the like.
The close analog of this behavior in the async1 is the C# state machine
zeroing out pointer-containing fields in the display struct upon
completing or faulting the task.
https://github.com/dotnet/roslyn/blob/f2df0ad6d3ef30ed033a794e7150a5600be50a95/src/Compilers/CSharp/Portable/Lowering/AsyncRewriter/AsyncMethodToStateMachineRewriter.cs#L186
https://github.com/dotnet/roslyn/blob/f2df0ad6d3ef30ed033a794e7150a5600be50a95/src/Compilers/CSharp/Portable/Lowering/AsyncRewriter/AsyncMethodToStateMachineRewriter.cs#L2241 parent 9155f26 commit d108713
File tree
1 file changed
+18
-4
lines changed- src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices
1 file changed
+18
-4
lines changedLines changed: 18 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | | - | |
| 241 | + | |
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
301 | 307 | | |
302 | 308 | | |
| 309 | + | |
303 | 310 | | |
304 | 311 | | |
305 | 312 | | |
| |||
373 | 380 | | |
374 | 381 | | |
375 | 382 | | |
376 | | - | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
377 | 390 | | |
378 | 391 | | |
| 392 | + | |
379 | 393 | | |
380 | 394 | | |
381 | 395 | | |
| |||
429 | 443 | | |
430 | 444 | | |
431 | 445 | | |
432 | | - | |
| 446 | + | |
433 | 447 | | |
434 | 448 | | |
435 | 449 | | |
| |||
0 commit comments