RandomSec/lib/jython-2.5.1/test/crashers/borrowed_ref_2.py
Vishal Talwar d0df704d8a added python code part of jython distribution in lib/jython-2.5.1
added python.path vm arg to startup script
fixed infinite loop in unwrap() when displaying sequences of sequences



git-svn-id: http://google-refine.googlecode.com/svn/trunk@509 7d457c2a-affb-35e4-300a-418c747d4874
2010-04-20 18:50:24 +00:00

39 lines
644 B
Python

"""
_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(im_func=D.__set__, im_self=d)
lst[i] = c.g # consume the free list of instancemethod objects
i += 1