summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-09-30 20:28:27 (GMT)
committerGitHub <noreply@github.com>2022-09-30 20:28:27 (GMT)
commit54bbb5e3363ef3634f1fd7521ba3f3c42c81a331 (patch)
tree137e682acc1ac3d9710a05715fa417be7235f9a4 /Lib
parenta5c503f296a104d8b5b2e917a2f1ef71be888e1b (diff)
downloadcpython-54bbb5e3363ef3634f1fd7521ba3f3c42c81a331.zip
cpython-54bbb5e3363ef3634f1fd7521ba3f3c42c81a331.tar.gz
cpython-54bbb5e3363ef3634f1fd7521ba3f3c42c81a331.tar.bz2
GH-97592: Fix crash in C remove_done_callback due to evil code (GH-97660)
Evil code could cause fut_callbacks to be cleared when PyObject_RichCompareBool is called. (cherry picked from commit 63780f4599acc2c5ee8af5f37ab76c162ad21065) Co-authored-by: Guido van Rossum <guido@python.org>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_asyncio/test_futures.py15
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 838147b..0126742 100644
--- a/Lib/test/test_asyncio/test_futures.py
+++ b/Lib/test/test_asyncio/test_futures.py
@@ -827,6 +827,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