Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Borrowing ~fn to &fn leaks #6141

Closed
brson opened this issue Apr 30, 2013 · 5 comments
Closed

Borrowing ~fn to &fn leaks #6141

brson opened this issue Apr 30, 2013 · 5 comments
Assignees
Labels
A-codegen Area: Code generation
Milestone

Comments

@brson
Copy link
Contributor

brson commented Apr 30, 2013

Fallout from demoding. This will leave a dangling allocation on the exchange heap.

fn run(f: &fn()) {
    f()
}

fn main() {
    let f: ~fn() = || ();
    run(f);
}
@brson
Copy link
Contributor Author

brson commented Apr 30, 2013

Nominating production ready.

@nikomatsakis
Copy link
Contributor

Huh. I'll take a quick look. What should be happening is that f is borrowed by run and freed by main. I thought I fixed this, guess not.

@graydon
Copy link
Contributor

graydon commented May 2, 2013

accepted for production ready

@nikomatsakis
Copy link
Contributor

Fix is in PR #6302.

bors added a commit that referenced this issue May 8, 2013
…r=brson

When autoborrowing a fn in trans, adjust the type of the datum to be `&fn`.

Fixes #6141.

r? @brson
@Aatch
Copy link
Contributor

Aatch commented May 9, 2013

This has been fixed now it seems.

@Aatch Aatch closed this as completed May 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation
Projects
None yet
Development

No branches or pull requests

4 participants