-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
closure in record triggers a memory leak and abort #1896
Comments
I am running into some leaks myself which look similar. I will assign to myself and hope that fixing my problems will fix this one too. |
Actually, I am not able to reproduce this problem. |
I do see it. Really surprising. |
When you rewrite it like this (with
I'm not actually sure what |
So, it would not be possible to store an |
Revisiting this, it's clear why there is a leak: an fn() type should not appear in a record. The drop glue will take no action. |
This issue appears to be fixed: the typechecker now rejects this program. Added it as a test case in 2a53640 . |
Another test case: use std;
type boxedFn = { theFn: fn () -> uint };
fn createClosure (closedUint: uint) -> boxedFn {
{ theFn: fn@ () -> uint { closedUint } }
}
#[test]
fn testForLeakage () {
let aFn: boxedFn = createClosure(10);
let myInt: uint = aFn.theFn();
assert myInt == 10;
} |
I think this will get fixed as part of the regions work on fns I need to do. |
#2202 specifically. |
This also leaks; is it the same issue?
It prints 11, 22, 33, 44, then proclaims:
|
same issue. |
|
|
This appears to be fixed (@bblum's example with |
Fixes rust-lang#1896 which was never truly fixed, just masked. The given tests would have failed had they used `~fn()` and not `@fn()`. They now result in compilation errors. Fixes rust-lang#2978. Necessary first step for rust-lang#2202, rust-lang#2263.
There seems to be an issue with closures in records and the type checker. This code segfaults with a leaked memory message:
However, if you remove
: t<()>
fromlet x: t<()> = { f: { || () } };
, it works just fine.The text was updated successfully, but these errors were encountered: