tail call causes memory leak in certain circumstances
ac1bc5b
Opened by Deleted user at
The following code
use std;
import std._vec;
fn inner(vec[int] dummy, int t) -> int {
if (t > 0) {
be inner(dummy, t - 1);
}
else {
ret 0;
}
}
fn main() {
inner(vec(1), 1);
}
gives rt: fatal, 'leaked memory in rust main loop (1 objects)' failed, rt/memory_region.cpp:99 1 objects Without the 'dummy' vector it is OK, i.e. fn inner(int t) -> int { if (t > 0) { be inner(t - 1); } else { ret 0; } }
fn main() {
inner(1);
}
Ah, it's leaking the argument slots to the slot the tail-call is originating from. Nice minimal case, thanks!
Found the problem, adding further-reduced test plus fix shortly.
Graydon Hoare at 2010-09-13 20:36:26
Er, the function the tail-call is originating from. Sigh, mondays.
Graydon Hoare at 2010-09-13 20:36:52
Fix leaking arg slots on tail calls. Closed by bc646d01c501f2566fd78057e23c283cfedc0eb0.
Graydon Hoare at 2010-09-13 20:37:34