ocaml-cross/opam-cross-windows

all executable that uses lwt crashes

Closed this issue · 10 comments

pirbo commented

I know, I'm the maintainer but I need help.

Take for example the program foo.ml:

let () = Lwt_main.run (Lwt_io.print "Hello\n")

opam install lwt-windows.2.6.0 and ocamlfind -toolchain windows opt -linkpkg -package lwt.unix -g -linkpkg -o foo foo.ml will work but

$ wine ./foo
Fatal error: exception Invalid_argument("Lwt_unix.on_signal: unavailable signal")

(It also crash on a real windows 7 and 10)

If you use the former version lwt-windows.2.5.2. it works. It get worse if you try to use lwt.2.7.0 or lwt.3.0.0 (available at https://github.com/pirbo/opam-cross-windows) where the result is now a segfault!

I have no idea how to tackle the issue...

pirbo commented

I've made progress thanks to @aantron !
The problem has nothing to do with an update of lwt. The culprit is moving from ocaml 4.02.3 to ocaml 4.04.0.
lwt.2.6.0 works fine with ocaml 4.02.3. lwt.2.5.2 crashes with ocaml 4.04.0.

I doubt that I helped in any way, except the most vague way possible. I am very interested in the outcome of this issue, however :)

@pirbo I would like to help you but I do not think I will have time to dig into that any time soon. You're on your own, sorry.

FTR, Lwt has been building, when not cross-compiling, on both 4.02.3 and 4.04.0 (but probably 4.04.1 now), continuously since before 2.6.0: Travis, AppVeyor. But I'm guessing that you already know this.

pirbo commented

And the final answer is .... lwt is incompatible with conf-flambda-windows !
Looking at ocamlfind -toolchain windows opt -config I realised that flambda: true. I uninstalled conf-flambda-windows, recompiled my toy example and it worked!

Have you tried (not cross-)compiling lwt under windows with flambda activated?
Anyway, I don't need flambda my problem is solved, thanks for your help

@pirbo Ohhhh... I know what happened here. The Sys.win32 constants get inlined by ocamlc instead of being called at runtime. But the cross-compiler and the runtime differ in what they think their value is. I filed #27 to track this.

Thanks @pirbo, @whitequark. I got really worried that Lwt might not be compatible with Flambda on Windows, but I hope it's just what @whitequark filed in #27. I'll watch both of these issues, in case Lwt itself turns out to need a fix.

And we haven't tried compiling with Flambda on Windows, no. Perhaps we will soon, but compiling Lwt on Windows is a bit of a maintenance nightmare so far, at least in CI...

Also cc'ing the rest of the maintainers: @mfp @c-cube.

In case I suffer an untimely demise or otherwise disappear, the Lwt "organization" will still know about this :)

Not that I have the slightest amount of competence when it comes to windows ^^