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

Weird bug when mixing futures and redirection #44

Closed
EliasC opened this issue Dec 10, 2014 · 8 comments
Closed

Weird bug when mixing futures and redirection #44

EliasC opened this issue Dec 10, 2014 · 8 comments
Assignees

Comments

@EliasC
Copy link
Contributor

EliasC commented Dec 10, 2014

The following program runs and prints Done! as expected:

class Foo
  def foo() : void
    ()

class Main
  def main() : void
    let x = new Foo in{
      get x.foo();
      print "Done!";
    }
bash-3.2$ ./foo
Done!
bash-3.2$

However, if we redirect stdout somewhere, the output disappears:

bash-3.2$ ./foo | xargs echo
bash-3.2$ 
bash-3.2$ ./foo > foo.txt
bash-3.2$ cat foo.txt
bash-3.2$ 

The problem only arises when redirecting stdout:

bash-3.2$ ./foo 2> foo.txt
Done!
bash-3.2$ cat foo.txt
bash-3.2$ 

The problem goes away if we get rid of the futures:

passive class Foo
  def foo() : void
    ()

class Main
  def main() : void
    let x = new Foo in{
      x.foo();
      print "Done!";
    }
bash-3.2$ ./foo | xargs echo
Done!
bash-3.2$ 

It also goes away if we add an embedded fflush to the end of the main method:

class Foo
  def foo() : void
    ()

class Main
  def main() : void
    let x = new Foo in{
      get x.foo();
      print "Done!";
      embed void
        fflush(NULL);
      end
    }
bash-3.2$ ./foo | xargs echo
Done!
bash-3.2$ 

It seems like some buffer for stdout is not flushed when the actor performing the print is suspended, waiting for the future to be fulfilled. Flushing in the end of the main function in the generated C-code (i.e. right before returning from int main()) does not fix the problem, so probably some other thread(s) needs to flush it. I'm not going to spend any more time on this until the new futures arrive.

@sophiaIC
Copy link
Contributor

That could the title of a song! ☺

@EliasC
Copy link
Contributor Author

EliasC commented Dec 10, 2014

@sophiaIC Please send me a playlist with the kind of music where "Weird bug when mixing futures and redirection" is a normal song title :)

@sophiaIC
Copy link
Contributor

until the new futures arrive.
I will, as soon as the new futures arrive.

@albertnetymk albertnetymk self-assigned this May 26, 2015
@albertnetymk
Copy link
Contributor

Is it still the case with the HEAD of master, 79f29b2?

@EliasC
Copy link
Contributor Author

EliasC commented May 26, 2015

This no longer seems to be an issue! I'll close this.

@EliasC EliasC closed this as completed May 26, 2015
@supercooldave
Copy link

Is there a test case to prove that this is no longer an issue?

@EliasC
Copy link
Contributor Author

EliasC commented May 26, 2015

@supercooldave The two tests touched by the related commit (345f43b) were the ones that needed the workaround. Since we don't know what was causing the issue before, it's hard to write a test that for it, but at least they both work (as well as the example above).

@supercooldave
Copy link

Good enough.

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