Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Sep 15, 2021

Backport of #59090 to release/6.0

/cc @davidfowl

Customer Impact

@AArnott reported a race condition with PipeReader where the ReadAsync operation could hang in some hard to reproduce cases when used with a cancellation token. The race resulting in hangs in various usages of pipelines in https://github.com/AArnott/Nerdbank.Streams (which is used in VS).

Testing

Manual testing. It's very hard to write a unit test for this scenario.

Risk

Low. The change was made to only affect a very narrow case (synchronous completion). Asserts were added to make sure existing invariants weren't broken.

…- There's a tight race where UnsafeRegister can fire inline and then ReadAsync never completes. This is because the cancellation token property has not been assigned yet so the callback noops. This change checks the result of the UnsafeRegister operation to see if ran synchronously and throws if it did. We also move any state transitions to after these checks to make sure the PipeAwaitable state doesn't change before throwing.
@AArnott
Copy link
Contributor

AArnott commented Sep 18, 2021

This fix is incomplete, and the original bug reactivated.

@davidfowl davidfowl closed this Sep 18, 2021
@jkotas jkotas deleted the backport/pr-59090-to-release/6.0 branch September 21, 2021 01:29
@jkotas jkotas restored the backport/pr-59090-to-release/6.0 branch September 21, 2021 01:29
@jkotas jkotas deleted the backport/pr-59090-to-release/6.0 branch September 21, 2021 01:30
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 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.

3 participants