diff options
author | Guido van Rossum <guido@python.org> | 2022-09-30 12:57:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-30 12:57:09 -0700 |
commit | 63780f4599acc2c5ee8af5f37ab76c162ad21065 (patch) | |
tree | 541db070bca69edcb73a5f344b14d4493080d57d /Lib/test/test_asyncio/test_futures.py | |
parent | e9d63760fea8748638f6e495b5b07bd1805c9591 (diff) | |
download | cpython-git-63780f4599acc2c5ee8af5f37ab76c162ad21065.tar.gz |
GH-97592: Fix crash in C remove_done_callback due to evil code (#97660)
Evil code could cause fut_callbacks to be cleared when PyObject_RichCompareBool is called.
Diffstat (limited to 'Lib/test/test_asyncio/test_futures.py')
-rw-r--r-- | Lib/test/test_asyncio/test_futures.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_futures.py b/Lib/test/test_asyncio/test_futures.py index 11d4273930..3dc6b658cf 100644 --- a/Lib/test/test_asyncio/test_futures.py +++ b/Lib/test/test_asyncio/test_futures.py @@ -837,6 +837,21 @@ class BaseFutureDoneCallbackTests(): fut.remove_done_callback(evil()) + def test_remove_done_callbacks_list_clear(self): + # see https://github.com/python/cpython/issues/97592 for details + + fut = self._new_future() + fut.add_done_callback(str) + + for _ in range(63): + fut.add_done_callback(id) + + class evil: + def __eq__(self, other): + fut.remove_done_callback(other) + + fut.remove_done_callback(evil()) + def test_schedule_callbacks_list_mutation_1(self): # see http://bugs.python.org/issue28963 for details |