Skip to content

tail call causes memory leak in certain circumstances #160

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
ghost opened this issue Sep 7, 2010 · 3 comments
Closed

tail call causes memory leak in certain circumstances #160

ghost opened this issue Sep 7, 2010 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 7, 2010

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);
}
@graydon
Copy link
Contributor

graydon commented Sep 13, 2010

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
Copy link
Contributor

graydon commented Sep 13, 2010

Er, the function the tail-call is originating from. Sigh, mondays.

@graydon
Copy link
Contributor

graydon commented Sep 13, 2010

Fix leaking arg slots on tail calls. Closed by bc646d0.

mbrubeck pushed a commit to mbrubeck/rust that referenced this issue Oct 17, 2011
oli-obk pushed a commit to oli-obk/rust that referenced this issue Jul 19, 2017
Also test subdirectories of `rust/src/test/run-pass`
keeperofdakeys pushed a commit to keeperofdakeys/rust that referenced this issue Dec 12, 2017
rchaser53 pushed a commit to rchaser53/rust that referenced this issue Jan 19, 2019
djtech-dev pushed a commit to djtech-dev/rust that referenced this issue Dec 9, 2021
Add an implementation of replace_all_uses_with for BasicBlock.
antoyo added a commit to antoyo/rust that referenced this issue Jun 7, 2022
Don't assume /bin/bash is available on every system.
celinval pushed a commit to celinval/rust-dev that referenced this issue Nov 13, 2024
Update to the version where the CBMC viewer is removed. This should
resolve the issues some people are having with the `run_kani.sh` script.
This issue was closed.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant