mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
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 63780f4599)
Co-authored-by: Guido van Rossum <guido@python.org>
This commit is contained in:
parent
a5c503f296
commit
54bbb5e336
3 changed files with 23 additions and 2 deletions
|
|
@ -827,6 +827,21 @@ def __eq__(self, other):
|
|||
|
||||
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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue