Skip to content

Possible to leak a non-static reference into a sendable proc #19261

Closed
@sfackler

Description

@sfackler

This successfully compiles, even though inner is a &Foo.

use std::sync::TaskPool;

struct Foo {
    p: TaskPool,
    q: uint
}

impl Foo {
    fn f(&self) {
        let inner = self.clone();
        self.p.execute(proc() {
            println!("{}", inner.q);
        });
    }
}

fn main() {}

For a more real example, see sfackler/r2d2@d864a78. It'll cause tests to segfault ~50% of the time.

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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions