Skip to content

Closure fails to borrow its upvar, causing memory unsafety #11873

Closed
@huonw

Description

@huonw
fn main() {
    let mut v = ~[1];
    let f = || v.push(2);
    let _w = v; // should be illegal, `v` is borrowed by `f`

    f(); // boom
}

The above crashes with a segfault.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.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