-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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-97592: Fix crash in C remove_done_callback due to evil code #97660
Conversation
gvanrossum
commented
Sep 29, 2022
•
edited by bedevere-bot
Loading
edited by bedevere-bot
- Issue: Bugs in asyncio.Future.remove_done_callback() cause segfault. #97592
10daef4
to
d407a0b
Compare
2ee888c
to
00b9536
Compare
@xiaxinmeng Feel free to add your review. |
Misc/NEWS.d/next/Library/2022-09-29-23-22-24.gh-issue-97592.tpJg_J.rst
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
class evil: | ||
def __eq__(self, other): | ||
fut.remove_done_callback(other) | ||
|
||
fut.remove_done_callback(evil()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Class names should normally use the CapWords convention.
class evil: | |
def __eq__(self, other): | |
fut.remove_done_callback(other) | |
fut.remove_done_callback(evil()) | |
class Evil: | |
def __eq__(self, other): | |
fut.remove_done_callback(other) | |
fut.remove_done_callback(Evil()) |
def __eq__(self, other): | ||
fut.remove_done_callback(other) | ||
|
||
fut.remove_done_callback(evil()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All callbacks added by fut.add_done_callback()
will be cleared when calling fut.remove_done_callback(Evil())
, but the return value will be the number of callbacks added last.
I'm not sure if we need to improve the return value of remove done callback
further, the current changes are good enough to fix the crash. :)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Thanks @gvanrossum for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
GH-97692 is a backport of this pull request to the 3.11 branch. |
…ythonGH-97660) Evil code could cause fut_callbacks to be cleared when PyObject_RichCompareBool is called. (cherry picked from commit 63780f4) Co-authored-by: Guido van Rossum <guido@python.org>
GH-97693 is a backport of this pull request to the 3.10 branch. |
…ythonGH-97660) Evil code could cause fut_callbacks to be cleared when PyObject_RichCompareBool is called. (cherry picked from commit 63780f4) Co-authored-by: Guido van Rossum <guido@python.org>
) Evil code could cause fut_callbacks to be cleared when PyObject_RichCompareBool is called. (cherry picked from commit 63780f4) Co-authored-by: Guido van Rossum <guido@python.org>
) Evil code could cause fut_callbacks to be cleared when PyObject_RichCompareBool is called. (cherry picked from commit 63780f4) Co-authored-by: Guido van Rossum <guido@python.org>
…ython#97660) Evil code could cause fut_callbacks to be cleared when PyObject_RichCompareBool is called.