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

Running Julia files on Windows in bash shell seems broken #32

Closed
WestleyArgentum opened this issue Sep 26, 2012 · 17 comments
Closed

Running Julia files on Windows in bash shell seems broken #32

WestleyArgentum opened this issue Sep 26, 2012 · 17 comments

Comments

@WestleyArgentum
Copy link

To reproduce this issue create some file "foo.jl" and, inside it, write something like:

"some_int = 42
print(some_int)"

Or maybe just a string of junk "fjdsjkd;dfsajeknnsb". I've played with it a bit and gotten a range of behavior.

Next fire up a terminal and say "julia foo.jl"

What comes out is occasionally the correct output but often only a single character and sometimes nothing at all... Also, note that I have no problems when running in repl mode.

@vtjnash
Copy link
Collaborator

vtjnash commented Sep 26, 2012

I can't reproduce this. Can you provide more information about your system configuration? What terminal are you using? Which version of Julia? Does using println instead of print help?

@WestleyArgentum
Copy link
Author

This is interesting. I've done more testing and I can repro it in cygwin bash shells and when running the Julia process using a wrapper called QProcess that is part of the Qt SDK. There is no problem running in the regular command prompt.

I'm using the windows binaries that are up on github and I've tried on machines with with and without cygwin and the Qt SDK (including a plain vanilla windows 7 virtual machine).

I believe the process is executing correctly because the output I do get is always the first chunk of the correct output. What seems to happen is that Julia exits before completely flushing standard out...

I see line 206 in client.jl: "atexit(()->flush(stdout_stream))"
It seems really unlikely, but is it possible that atexit() isn't working properly? I've had issues with it in the past (although supposedly those days are long gone).

@vtjnash
Copy link
Collaborator

vtjnash commented Sep 27, 2012

Thanks! I had tried it in MinGW and the regular command prompt and, as you said, it worked fine there.

If you look at the source code for the Windows binaries, I've had to comment out that line since libuv doesn't have a notion of flush.

Unless @loladiro knows how to add a flush method more directly, perhaps we should enter uv_run() at the end with one task that deletes all items that it can reach with uv_walk, then waits for libuv to shutdown the event loop.

@Keno
Copy link
Owner

Keno commented Sep 27, 2012

We should probably wait for the close_cb on stdout.

@WestleyArgentum
Copy link
Author

Ahhh, I can't believe I was looking at client.jl in the main repository instead of this one >.<

Anyway, thanks very much for looking at this... how about we give it a shot? Are you guys able to compile the source from this repo on windows using the main makefile or are there tricks that I have to know about? I've been unsuccessful a couple times but I may just be missing dependencies...

@vtjnash
Copy link
Collaborator

vtjnash commented Sep 27, 2012

Alright, I'll see about adding some code that tries to close everything and waits for libuv to exit more gracefully. I think that is more general then just waiting for close_cb on stdout? (although I may try that first to verify, when I can get some time free)

If you have MinGW with gcc, you should be able to pretty much just run make in the top level and everything should build. I'm not aware of any other dependancies, but perhaps Keno remembers others? I don't know what will happen if you try to build it in Cygwin, but I don't see why it shouldn't be possible (possibly requiring the use of the MinGW compiler and possibly requiring various flags like CC=gcc-mingw-4.5, etc?). If you can add a bug report with the specific error message, it can help us identify what should be added to the README, or fix.

@WestleyArgentum
Copy link
Author

I really do hate to pester you like this, but have you had any time to look at this issue since we last talked?

@vtjnash
Copy link
Collaborator

vtjnash commented Oct 2, 2012

Thanks for the reminder, I had almost forgotten. I just took a look and found that it is in fact essential (on Windows) to close open pipes and streams before exiting to ensure the write callbacks get executed by Windows. TTY's are handled differently, so normal consoles worked as expected. I'll try to get a fix out for this soon.

@WestleyArgentum
Copy link
Author

Awesome, I look forward to it :)

@WestleyArgentum
Copy link
Author

@vtjnash: I just noticed your commit from a couple days ago, does that seem to solve the problem?

@vtjnash
Copy link
Collaborator

vtjnash commented Oct 5, 2012

I showed that the concept was right, but that commit wasn't quite right. Libuv may need to be updated and fixed to actually correct this, but I won't be sure until there is a clear testcase (in c) that can demonstrate the failure.

@WestleyArgentum
Copy link
Author

@vtjnash: I'm not sure if we've spoken in person before or not. I'm working at Forio on a project relating to Julia and, well, Windows support has become a very time critical thing for us. Could you please send me an email at whennigh@forio.com so that we can discuss this?

@vtjnash vtjnash closed this as completed in 61ab226 Oct 6, 2012
@vtjnash
Copy link
Collaborator

vtjnash commented Oct 6, 2012

note: simplest test case for this was ./julia test.jl | cat -

@WestleyArgentum I appreciate your urgency, but this is not my day job. Additionally, I sometimes have to sleep on the issues for a few days to figure out where I went wrong. (the commit from a few days ago was only a fraction of what I eventually tested to no avail)

@WestleyArgentum
Copy link
Author

@vtjnash: Sorry, I didn't mean to come across that demanding and I certainly don't mean to pin this on you. I just wasn't quite sure what you needed and, because we were dependent, I wanted to find some way help...

Thanks so much for putting in so much time on this, heh, and I totally know what you mean by needing to sleep on things.

Would you be willing to make and put up windows binaries for this? We can do some pretty extensive testing to make sure everything is alright if you want :)

@vtjnash
Copy link
Collaborator

vtjnash commented Oct 8, 2012

@WestleyArgentum no problem. I tried building binaries for windows, but they are failing tests either because something is getting into the garbage collector uninitialized, or because the stack pointer is getting corrupted by gcc-compiled code, or both. I currently suspect the former. If you have time to try to backtrace this GC value to it's origin (revealed by running julia-debug-basic with gcc), we could probably get the binaries released sooner.

@JeffBezanson
Copy link
Collaborator

Does the uninitialized value bug exist on other platforms too?

@vtjnash
Copy link
Collaborator

vtjnash commented Oct 8, 2012

moving discussion to issue #34

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