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

Memory management bug probably in tit_lazy, likely related to futures #35

Closed
kaeluka opened this issue Aug 18, 2014 · 6 comments
Closed

Comments

@kaeluka
Copy link
Contributor

kaeluka commented Aug 18, 2014

This program demonstrates a bug, pbly in the futures implementation:

program.enc:

#! /usr/bin/env encorec -run

class Foo {
  def bar() : int {
    print "hello";
    84
  }

  def baz() : int {
    this.bar()
  }
}

class Main {
  def main() : void {
    let l = new Foo in {
        print get l.baz();
        print get l.baz()
    };
  }
}

When run in a loop, the program will output:

$ while [ true ]; do ./program.enc || break ; done
hello
84
hello
84
-- snip --
hello
hello
84
-- snip --
...

In the last lines, you see that a 84 did not appear. As far as I can tell, the future get did not return, instead the executable returns with a normal (!) exit, as the break does not get triggered.

Edit: Also, sometimes I get

$ ./program.enc
hello
report(845,0x7fff7322b310) malloc: *** error for object 0x7fbcb3600338: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug    ...
@EliasC
Copy link
Contributor

EliasC commented Aug 18, 2014

I get the same kind of behavior, as well as the occasional

$ ./foo.enc
hello
84
hello
foo(69137,0x7fff79a9b310) malloc: *** error for object 0x7fc31bc04128: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug

Could it have to do with GC of futures?

@TobiasWrigstad
Copy link
Contributor

I may have found this bug. It seems that under certain circumstances, we are freeing a lazy_tit too eagerly. You could try to remove the free call in garbage_collect_stack in tit_lazy.c and see if that removes your problem.

@TobiasWrigstad TobiasWrigstad changed the title Futures buggy Memory management bug probably in tit_lazy, likely related to futures Dec 8, 2014
@EliasC
Copy link
Contributor

EliasC commented Dec 9, 2014

@TobiasWrigstad Removing the free seems to fix the problem! But I guess that this means that we're now leaking something instead... Is this also something that (hopefully) will be fixed with the new future implementation?

@TobiasWrigstad
Copy link
Contributor

Kiko and Albert are rewriting the lightweight threads (not entirely unrelated to futures, but not the same thing either). All tit_* code will soon go.

@kikofernandez
Copy link
Contributor

That’s correct. Moreover, the eager and lazy implementation were broken on Linux. Sometimes the program finish and sometimes it crashes.
Our current implementation (not yet finish) does not crash on Mac nor on Linux.

@kikofernandez
Copy link
Contributor

tested the current implementation. working on Mac and Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants