collected my segfaulting Python examples from the SF trackers
(is the purpose of the crashers directory to scare people? :-)
This commit is contained in:
parent
f60cd47f10
commit
b4b5a7601b
|
@ -0,0 +1,12 @@
|
|||
|
||||
# http://python.org/sf/1174712
|
||||
|
||||
import types
|
||||
|
||||
class X(types.ModuleType, str):
|
||||
"""Such a subclassing is incorrectly allowed --
|
||||
see the SF bug report for explanations"""
|
||||
|
||||
if __name__ == '__main__':
|
||||
X('name') # segfault: ModuleType.__init__() reads
|
||||
# the dict at the wrong offset
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
# http://python.org/sf/1202533
|
||||
|
||||
import new, operator
|
||||
|
||||
class A:
|
||||
pass
|
||||
A.__mul__ = new.instancemethod(operator.mul, None, A)
|
||||
|
||||
if __name__ == '__main__':
|
||||
A()*2 # segfault: infinite recursion in C
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
# http://python.org/sf/1202533
|
||||
|
||||
class A(str):
|
||||
__get__ = getattr
|
||||
|
||||
if __name__ == '__main__':
|
||||
a = A('a')
|
||||
A.a = a
|
||||
a.a # segfault: infinite recursion in C
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
# http://python.org/sf/1202533
|
||||
|
||||
class A(object):
|
||||
pass
|
||||
A.__call__ = A()
|
||||
|
||||
if __name__ == '__main__':
|
||||
A()() # segfault: infinite recursion in C
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
# http://python.org/sf/1202533
|
||||
|
||||
if __name__ == '__main__':
|
||||
lst = [apply]
|
||||
lst.append(lst)
|
||||
apply(*lst) # segfault: infinite recursion in C
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
# http://python.org/sf/1267884
|
||||
|
||||
import types
|
||||
|
||||
class C:
|
||||
__str__ = types.InstanceType.__str__
|
||||
|
||||
if __name__ == '__main__':
|
||||
str(C()) # segfault: infinite recursion in C
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
# http://python.org/sf/1303614
|
||||
|
||||
class Strange(object):
|
||||
def __hash__(self):
|
||||
return hash('hello')
|
||||
|
||||
def __eq__(self, other):
|
||||
x.__dict__ = {} # the old x.__dict__ is deallocated
|
||||
return False
|
||||
|
||||
|
||||
class X(object):
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
v = 123
|
||||
x = X()
|
||||
x.__dict__ = {Strange(): 42,
|
||||
'hello': v+456}
|
||||
x.hello # segfault: the above dict is accessed after it's deallocated
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
# http://python.org/sf/1303614
|
||||
|
||||
class Y(object):
|
||||
pass
|
||||
|
||||
class type_with_modifiable_dict(Y, type):
|
||||
pass
|
||||
|
||||
class MyClass(object):
|
||||
"""This class has its __dict__ attribute completely exposed:
|
||||
user code can read, reassign and even delete it.
|
||||
"""
|
||||
__metaclass__ = type_with_modifiable_dict
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
del MyClass.__dict__ # if we set tp_dict to NULL,
|
||||
print MyClass # doing anything with MyClass segfaults
|
Loading…
Reference in New Issue