Skip to content

Fix race in channel select/cancel #1592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2019
Merged

Fix race in channel select/cancel #1592

merged 1 commit into from
Oct 3, 2019

Conversation

elizarov
Copy link
Contributor

@elizarov elizarov commented Oct 2, 2019

This bug was introduced by PR #1524. It was reproducing when there
is a regular "send" operation on one side of a channel and
"select { onReceive }" on another side of the channel and the
"send" coroutine gets cancelled. The problem is that
SendElement.tryResumeSend implementation was calling finishPrepare
before it has successfully resumed continuation, so if that
continuation was already cancelled, the code in "finishPrepare" had
already stored the wrong affected node which it would later try to
call "completeResume" on.

This patch also adds hexAddress to the debug toString method of
all internal node classes in channel implementation.

Fixes #1588

@elizarov elizarov marked this pull request as ready for review October 2, 2019 12:01
@elizarov elizarov requested a review from qwwdfsad October 2, 2019 12:02
This bug was introduced by PR #1524. It was reproducing when there
is a regular "send" operation on one side of a channel and
"select { onReceive }" on another side of the channel and the
"send" coroutine gets cancelled. The problem is that
SendElement.tryResumeSend implementation was calling finishPrepare
before it has successfully resumed continuation, so if that
continuation was already cancelled, the code in "finishPrepare" had
already stored the wrong affected node which it would later try to
call "completeResume" on.

This patch also adds hexAddress to the debug toString method of
all internal node classes in channel implementation.

Fixes #1588
@elizarov elizarov merged commit d9d3574 into develop Oct 3, 2019
@elizarov elizarov deleted the select-fix branch October 3, 2019 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants