summaryrefslogtreecommitdiffstats
path: root/Lib/test/crashers/loosing_dict_ref.py
blob: f44370b9a5971f63e7d8728bd88e464e4167c6b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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