Skip to content

Immutability: Missing write barrier in optimized bytecode #104

@xFrednet

Description

@xFrednet

Bug found by Vanja:

class C:
    def __init__(self):
        self.a = [1,2,3]

    def f(self):
        self.a.append(4)
        freeze(self.a)

foo = C()       #     foo.a: [1, 2, 3]
foo.f()         # ok, foo.a: [1, 2, 3, 4]
foo.f()         # ok, foo.a: [1, 2, 3, 4, 4]
foo.a.append(5) # TypeError: object of type list is immutable

This looks similar to other bugs I saw with regions. It's very likely that C.f gets optimized and the optimized bytecode is missing the write barrier

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions