Skip to content

Fix cancellation race condition in Parallel.ForEachAsync#47396

Merged
stephentoub merged 1 commit intodotnet:masterfrom
stephentoub:foreachasynccancel
Jan 25, 2021
Merged

Fix cancellation race condition in Parallel.ForEachAsync#47396
stephentoub merged 1 commit intodotnet:masterfrom
stephentoub:foreachasynccancel

Conversation

@stephentoub
Copy link
Member

If cancellation is requested at just the "wrong" time, we may end up canceling the operation but reporting it as a successful completion, due to our relying on _registration.Token being the caller-provided token, but that not being the case if cancellation was requested prior to UnsafeRegister being called, in which case it'll return a default registration.

Fixes #47360
cc: @tarekgh

If cancellation is requested at just the "wrong" time, we may end up canceling the operation but reporting it as a successful completion, due to our relying on _registration.Token being the caller-provided token, but that not being the case if cancellation was requested prior to UnsafeRegister being called, in which case it'll return a default registration.
@ghost
Copy link

ghost commented Jan 25, 2021

Tagging subscribers to this area: @tarekgh
See info in area-owners.md if you want to be subscribed.

Issue Details

If cancellation is requested at just the "wrong" time, we may end up canceling the operation but reporting it as a successful completion, due to our relying on _registration.Token being the caller-provided token, but that not being the case if cancellation was requested prior to UnsafeRegister being called, in which case it'll return a default registration.

Fixes #47360
cc: @tarekgh

Author: stephentoub
Assignees: -
Labels:

area-System.Threading.Tasks

Milestone: 6.0.0

@stephentoub stephentoub merged commit 004eb75 into dotnet:master Jan 25, 2021
@stephentoub stephentoub deleted the foreachasynccancel branch January 25, 2021 17:01
@ghost ghost locked as resolved and limited conversation to collaborators Feb 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ParallelForEachAsyncTests failing on Linux Arm

2 participants