[Python-checkins] cpython: Issue #14211: Oops, I removed the wrong file :-)

victor.stinner python-checkins at python.org
Fri Mar 9 00:52:33 CET 2012


http://hg.python.org/cpython/rev/2cc44cd8098e
changeset:   75499:2cc44cd8098e
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Fri Mar 09 00:52:07 2012 +0100
summary:
  Issue #14211: Oops, I removed the wrong file :-)

files:
  Lib/test/crashers/borrowed_ref_1.py |  29 ++++++++++++
  Lib/test/crashers/borrowed_ref_2.py |  38 -----------------
  2 files changed, 29 insertions(+), 38 deletions(-)


diff --git a/Lib/test/crashers/borrowed_ref_1.py b/Lib/test/crashers/borrowed_ref_1.py
new file mode 100644
--- /dev/null
+++ b/Lib/test/crashers/borrowed_ref_1.py
@@ -0,0 +1,29 @@
+"""
+_PyType_Lookup() returns a borrowed reference.
+This attacks the call in dictobject.c.
+"""
+
+class A(object):
+    pass
+
+class B(object):
+    def __del__(self):
+        print('hi')
+        del D.__missing__
+
+class D(dict):
+    class __missing__:
+        def __init__(self, *args):
+            pass
+
+
+d = D()
+a = A()
+a.cycle = a
+a.other = B()
+del a
+
+prev = None
+while 1:
+    d[5]
+    prev = (prev,)
diff --git a/Lib/test/crashers/borrowed_ref_2.py b/Lib/test/crashers/borrowed_ref_2.py
deleted file mode 100644
--- a/Lib/test/crashers/borrowed_ref_2.py
+++ /dev/null
@@ -1,38 +0,0 @@
-"""
-_PyType_Lookup() returns a borrowed reference.
-This attacks PyObject_GenericSetAttr().
-
-NB. on my machine this crashes in 2.5 debug but not release.
-"""
-
-class A(object):
-    pass
-
-class B(object):
-    def __del__(self):
-        print("hi")
-        del C.d
-
-class D(object):
-    def __set__(self, obj, value):
-        self.hello = 42
-
-class C(object):
-    d = D()
-
-    def g():
-        pass
-
-
-c = C()
-a = A()
-a.cycle = a
-a.other = B()
-
-lst = [None] * 1000000
-i = 0
-del a
-while 1:
-    c.d = 42         # segfaults in PyMethod_New(__func__=D.__set__, __self__=d)
-    lst[i] = c.g     # consume the free list of instancemethod objects
-    i += 1

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list