Plan 9 from Bell Labs’s /usr/web/sources/contrib/bichued/root/sys/lib/python/test/crashers/loosing_dict_ref.py

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.



# 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

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.