Skip to content

Direct Rc/Weak cycle causes double free #12046

Closed
@huonw

Description

@huonw
use std::rc::{Rc, Weak};
use std::cell::RefCell;

struct Cycle {
    x: RefCell<Option<Weak<Cycle>>>
}

fn main() {
    let a = Rc::new(Cycle { x: RefCell::new(None) });
    let b = a.clone().downgrade();
    *a.borrow().x.borrow_mut().get() = Some(b);
}

crashes with a double free when run, with and without optimisations.

I'm investigating.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions