Skip to content

Running into segmentation fault with new closures #16774

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
cburgdorf opened this issue Aug 26, 2014 · 1 comment · Fixed by #18555
Closed

Running into segmentation fault with new closures #16774

cburgdorf opened this issue Aug 26, 2014 · 1 comment · Fixed by #18555
Labels
A-closures Area: Closures (`|…| { … }`) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@cburgdorf
Copy link
Contributor

I'm playing with the new closures and ran into a segmentation fault when I tried this:

    #![feature(unboxed_closures)]
    #![feature(overloaded_calls)]

    fn main() {
        let mut test = box 5i;

        let change = ref |:| { *test = 10 };
        change();

        println!("{}", test);
    }

Not sure if this was reported before or a known issue but I thought I better report it.

/cc @pcwalton

@aturon aturon mentioned this issue Oct 16, 2014
47 tasks
@bkoropoff
Copy link
Contributor

I think this was caused by capture-by-ref closures actually being emitted as capture-by-value in trans, resulting in the box being freed twice. This was fixed by #17731. It might be worth adding a test for this specific case, though.

@huonw huonw added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 19, 2014
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-closures Area: Closures (`|…| { … }`) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants