Fix assert / ObjectDisposedException in PLINQ handling of AggregateException (#47711)
PLINQ's QueryTaskGroupState handles joining with queued tasks, and handles the exceptions that emerge from waiting on them. AggregateExceptions are special-cased, and are flattened to eliminate extra levels that may have been added explicitly or implicitly; the code then checks to see whether all of the exceptions contained in the aggregate represent cancellation. However, it fails to account for the possibility that there are no exceptions it contains, which could happen if the only exceptions thrown are themselves empty AggregateExceptions. If that happens, the code makes some invalid assumptions that lead to a failed assert and then throwing an ObjectDisposedException. The fix is just to check whether the flattened AggregateException is empty and to treat that not as cancellation but as a normal exception.
Showing
想要评论请 注册 或 登录