Skip to content
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

gh-92530: Fix an issue that occurred after interrupting threading.Condition.notify #92534

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented May 9, 2022

Fixes #92530.

@serhiy-storchaka serhiy-storchaka added type-bug An unexpected behavior, bug, or error needs backport to 3.9 only security fixes needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes labels May 9, 2022
@serhiy-storchaka serhiy-storchaka linked an issue May 9, 2022 that may be closed by this pull request
Copy link
Contributor

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the deque entirely undoes the optimisation from https://bugs.python.org/issue17385

@serhiy-storchaka
Copy link
Member Author

No, self._waiters is still a deque.

@miss-islington
Copy link
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10, 3.11.
🐍🍒⛏🤖

@serhiy-storchaka serhiy-storchaka deleted the threading-condition-notify-interrupt branch May 16, 2022 05:25
@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label May 16, 2022
@bedevere-bot
Copy link

GH-92829 is a backport of this pull request to the 3.11 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 16, 2022
…ng.Condition.notify (pythonGH-92534)

If Condition.notify() was interrupted just after it released the waiter lock,
but before removing it from the queue, the following calls of notify() failed
with RuntimeError: cannot release un-acquired lock.
(cherry picked from commit 70af994)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 16, 2022
…ng.Condition.notify (pythonGH-92534)

If Condition.notify() was interrupted just after it released the waiter lock,
but before removing it from the queue, the following calls of notify() failed
with RuntimeError: cannot release un-acquired lock.
(cherry picked from commit 70af994)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label May 16, 2022
@bedevere-bot
Copy link

GH-92830 is a backport of this pull request to the 3.10 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 16, 2022
…ng.Condition.notify (pythonGH-92534)

If Condition.notify() was interrupted just after it released the waiter lock,
but before removing it from the queue, the following calls of notify() failed
with RuntimeError: cannot release un-acquired lock.
(cherry picked from commit 70af994)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label May 16, 2022
@bedevere-bot
Copy link

GH-92831 is a backport of this pull request to the 3.9 branch.

@vstinner
Copy link
Member

I reviewed your fix twice. Ok, now it makes sense and the comment is enough to explain the fix and the code.

It might be safe to check if the waiter is already released by calling the .locked() method, but I don't think that it's worth it and it might introduce new subtle concurrency issues. In short, the fix is correct :-)

@serhiy-storchaka
Copy link
Member Author

EAFP is so superior to LBYL here, that the latter I did not even consider.

ambv pushed a commit that referenced this pull request May 16, 2022
…dition.notify (GH-92534) (GH-92831)

If Condition.notify() was interrupted just after it released the waiter lock,
but before removing it from the queue, the following calls of notify() failed
with RuntimeError: cannot release un-acquired lock.
(cherry picked from commit 70af994)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
ambv pushed a commit that referenced this pull request May 16, 2022
…dition.notify (GH-92534) (GH-92830)

If Condition.notify() was interrupted just after it released the waiter lock,
but before removing it from the queue, the following calls of notify() failed
with RuntimeError: cannot release un-acquired lock.
(cherry picked from commit 70af994)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington added a commit that referenced this pull request May 17, 2022
…ing.Condition.notify (GH-92534) (GH-92829)

If Condition.notify() was interrupted just after it released the waiter lock,
but before removing it from the queue, the following calls of notify() failed
with RuntimeError: cannot release un-acquired lock.
(cherry picked from commit 70af994)


Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

Automerge-Triggered-By: GH:serhiy-storchaka
hello-adam pushed a commit to hello-adam/cpython that referenced this pull request Jun 2, 2022
…ng.Condition.notify (pythonGH-92534) (pythonGH-92831)

If Condition.notify() was interrupted just after it released the waiter lock,
but before removing it from the queue, the following calls of notify() failed
with RuntimeError: cannot release un-acquired lock.
(cherry picked from commit 70af994)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issues when Condition.notify() is interrupted
6 participants