[proxy] web.archive.org← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light
/ cpython Public
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

bpo-26819: Prevent proactor double read on resume #6921

Merged
merged 1 commit into from May 20, 2018

Conversation

Copy link
Contributor

CtrlZvi commented May 16, 2018

The proactor event loop has a race condition when reading with
pausing/resuming. resume_reading() unconditionally schedules the read
function to read from the current future. If resume_reading() was
called before the previously scheduled done callback fires, this results
in two attempts to get the data from the most recent read and an
assertion failure. This commit tracks whether or not resume_reading
needs to reschedule the callback to restart the loop, preventing a
second attempt to read the data.

https://bugs.python.org/issue26819

The proactor event loop has a race condition when reading with
pausing/resuming. `resume_reading()` unconditionally schedules the read
function to read from the current future. If `resume_reading()` was
called before the previously scheduled done callback fires, this results
in two attempts to get the data from the most recent read and an
assertion failure. This commit tracks whether or not `resume_reading`
needs to reschedule the callback to restart the loop, preventing a
second attempt to read the data.
Copy link
Member

1st1 commented May 17, 2018

@asvetlov Andrew, can you take a look?

Copy link
Member

1st1 commented May 17, 2018

Looks OK to my eyes.

Copy link
Contributor Author

CtrlZvi commented May 19, 2018

I noticed that the first run of test_asyncio on appveyor failed, but the rerun with -v succeeded. I've been unable to reproduce that failure locally, and I'm not seeing anything I missed, so I'm not sure what might be the problem. Are there any known issues with test_asyncio?

asvetlov merged commit 4151061 into python:master May 20, 2018
Copy link
Contributor

miss-islington commented May 20, 2018

Thanks @CtrlZvi for the PR, and @asvetlov for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7.
🐍🍒🤖

Copy link

bedevere-bot commented May 20, 2018

@asvetlov: Please replace # with GH- in the commit message next time. Thanks!

Copy link
Contributor

asvetlov commented May 20, 2018

thanks!

Copy link

bedevere-bot commented May 20, 2018

GH-7004 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 20, 2018
The proactor event loop has a race condition when reading with
pausing/resuming. `resume_reading()` unconditionally schedules the read
function to read from the current future. If `resume_reading()` was
called before the previously scheduled done callback fires, this results
in two attempts to get the data from the most recent read and an
assertion failure. This commit tracks whether or not `resume_reading`
needs to reschedule the callback to restart the loop, preventing a
second attempt to read the data.
(cherry picked from commit 4151061)

Co-authored-by: CtrlZvi <viz+github@flippedperspective.com>
Copy link
Contributor

miss-islington commented May 20, 2018

Sorry, @CtrlZvi and @asvetlov, I could not cleanly backport this to 3.6 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 4151061855b571bf8a7579daa7875b8e243057b9 3.6

miss-islington added a commit that referenced this pull request May 20, 2018
The proactor event loop has a race condition when reading with
pausing/resuming. `resume_reading()` unconditionally schedules the read
function to read from the current future. If `resume_reading()` was
called before the previously scheduled done callback fires, this results
in two attempts to get the data from the most recent read and an
assertion failure. This commit tracks whether or not `resume_reading`
needs to reschedule the callback to restart the loop, preventing a
second attempt to read the data.
(cherry picked from commit 4151061)

Co-authored-by: CtrlZvi <viz+github@flippedperspective.com>
Copy link
Contributor

asvetlov commented May 20, 2018

@CtrlZvi 3.6 branch is quite different from 3.7/master.
Could you backport the change by hands?

Copy link
Contributor Author

CtrlZvi commented May 20, 2018

I will take a look!

CtrlZvi added a commit to CtrlZvi/cpython that referenced this pull request May 22, 2018
The proactor event loop has a race condition when reading with
pausing/resuming. `resume_reading()` unconditionally schedules the read
function to read from the current future. If `resume_reading()` was
called before the previously scheduled done callback fires, this results
in two attempts to get the data from the most recent read and an
assertion failure. This commit tracks whether or not `resume_reading`
needs to reschedule the callback to restart the loop, preventing a
second attempt to read the data..
(cherry picked from commit 4151061)

Co-authored-by: CtrlZvi <viz+github@flippedperspective.com>
Copy link

bedevere-bot commented May 25, 2018

GH-7110 is a backport of this pull request to the 3.6 branch.

asvetlov pushed a commit that referenced this pull request May 25, 2018
)

The proactor event loop has a race condition when reading with
pausing/resuming. `resume_reading()` unconditionally schedules the read
function to read from the current future. If `resume_reading()` was
called before the previously scheduled done callback fires, this results
in two attempts to get the data from the most recent read and an
assertion failure. This commit tracks whether or not `resume_reading`
needs to reschedule the callback to restart the loop, preventing a
second attempt to read the data..
(cherry picked from commit 4151061)

Co-authored-by: CtrlZvi <viz+github@flippedperspective.com>
yahya-abou-imran pushed a commit to yahya-abou-imran/cpython that referenced this pull request Nov 2, 2018
The proactor event loop has a race condition when reading with
pausing/resuming. `resume_reading()` unconditionally schedules the read
function to read from the current future. If `resume_reading()` was
called before the previously scheduled done callback fires, this results
in two attempts to get the data from the most recent read and an
assertion failure. This commit tracks whether or not `resume_reading`
needs to reschedule the callback to restart the loop, preventing a
second attempt to read the data.
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.

None yet

6 participants