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

Fix crash when run from xboard #17

Closed
abahm opened this issue Oct 29, 2016 · 10 comments
Closed

Fix crash when run from xboard #17

abahm opened this issue Oct 29, 2016 · 10 comments
Labels

Comments

@abahm
Copy link
Owner

abahm commented Oct 29, 2016

No description provided.

@abahm abahm added the bug label Oct 29, 2016
@abahm
Copy link
Owner Author

abahm commented Oct 29, 2016

xboard.debug.txt

@abahm
Copy link
Owner Author

abahm commented Oct 29, 2016

Here is the xboard protocol, note section 6.

Here is a reference implementation.

@abahm
Copy link
Owner Author

abahm commented Oct 29, 2016

This problem was observed yesterday, and seems to be caused deep in julia internals.
xboard.debug.txt
Playing the xboard_loop() by hand in the REPL doesn't trigger the issue.

@abahm
Copy link
Owner Author

abahm commented Nov 1, 2016

@abahm
Copy link
Owner Author

abahm commented Nov 1, 2016

Also note that we can flush c style...
http://docs.julialang.org/en/release-0.5/stdlib/libc/

but I haven't yet found how to call it (its not in Base namespace)

@abahm
Copy link
Owner Author

abahm commented Nov 1, 2016

Also worth understanding - how julia sets up its environment:
http://docs.julialang.org/en/release-0.5/devdocs/init/?highlight=STDOUT

@abahm
Copy link
Owner Author

abahm commented Nov 1, 2016

The problem happens on all Win/Mac/Arch, with xboard 4.8 and 4.9 (haven't tested earlier versions). The problem seems to have always been present (checking out earlier commits the problem persists). It appears to just be something fundamental in how julia receives / sends on these pipes.

I've reproduced the problem with simply xboard_bug.jl

To reproduce, run the command line:
xboard -debug -fcp "julia xboard_bug.jl"

this asks xboard to output its debug info of the io.

Make a couple of moves for white, one or two black moves will happen, but then xboard will report the julia crash.

@kwilsonpdx
Copy link
Collaborator

Running strace:

xboard -debug -engineDebugOutput 2 -fcp "julia xboard.jl"
sudo strace -p 10440 -e read,write -s 1000000 >& strace_xjulia.txt
sudo strace -p 10437 -e read,write -s 1000000 >& strace_xboard.txt 

strace_xboard.txt
strace_xjulia.txt

@abahm
Copy link
Owner Author

abahm commented Nov 1, 2016

The source for xboard is available at: http://ftp.gnu.org/gnu/xboard/

and childio.c contains the relevant pipes code. Reading about pipes in Linux / POSIX at: http://tldp.org/LDP/lpg/node9.html

Looking at the strace for xboard, there are some weird long read calls. Learning about strace

Maybe julia is spitting out information on the STDERR tied to STDOUT?
JuliaLang/julia#7633

@abahm abahm closed this as completed Nov 2, 2016
@abahm
Copy link
Owner Author

abahm commented Nov 2, 2016

We must set feature SIGINT=0 to prevent xboard from sending this to julia. Section 7 of the protocol.

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

No branches or pull requests

2 participants