Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Null reference when a variable name of the deleted object is assigned the second time. #4861

Open
@xiaxinmeng

Description

@xiaxinmeng

This code defines a class called C and creates an instance of this class named c. Inside the del method, a new instance of the C class is created and assigned to a variable c. Then, the code creates a variable d which contains a range object from 0 to 9. Finally, the variable c is assigned to the value of d, which means that the original instance of the C class created earlier is no longer referenced and will be garbage collected, while rustpython fails doing that and get panicked.

class C:
    def __del__(self):
        c = C()
c = C()
d = range(10) 
c = d    #crash here

Crash message:

Exception ignored in: <object function repr() failed>
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: PyBaseException', vm/src/stdlib/sys.rs:593:59
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Environment:
Ubuntu 18.04
rustpython v0.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-vmArea: virtual machineC-bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions