Hello,
I'm trying to port OCaml 4.0.3 environment to Minix3 platform. The compiler test suite is invaluable to check that everything is working correctly. Minix3 does not have native threads and the tests have to be adapted to use vmthreads only. I've been hitting a wall for a few days because the
fileio.ml test was failing:
... testing 'fileio.ml': ocamlcThread 19 killed on uncaught exception Sys_blocked_io Thread 20 killed on uncaught exception Sys_blocked_io
cmp: EOF on /tmp/testio30da35
The test is compiled and then run with commands, from OCaml testsuite directory:
$ ../byterun/ocamlrun ../ocamlc -g -nostdlib -I ../stdlib -w a -vmthread -I ../otherlibs/threads -I ../otherlibs/unix unix.cma threads.cma -I ../testsuite/lib tests/lib-threads/fileio.ml -o program $ ../byterun/ocamlrun -b -I ../stdlib -I ../otherlibs/threads -I ../otherlibs/unix program tests/lib-threads/fileio.ml 256-byte chunks, 256-byte chunks
4096-byte chunks, 4096-byte chunks
65536-byte chunks, 65536-byte chunks
256-byte chunks, 4096-byte chunks
4096-byte chunks, 256-byte chunks
4096-byte chunks, 65536-byte chunks
263-byte chunks, 4011-byte chunks
613-byte chunks, 1027-byte chunks
Thread 19 killed on uncaught exception Sys_blocked_io
Raised by primitive operation at unknown location
Called from file "tests/lib-threads/fileio.ml", line 68, characters 6-38 Re-raised at file "tests/lib-threads/fileio.ml", line 53, characters 4-149 Called from file "thread.ml", line 131, characters 8-14 Thread 20 killed on uncaught exception Sys_blocked_io
Raised by primitive operation at file "pervasives.ml", line 415, characters 4-749 Called from file "tests/lib-threads/fileio.ml", line 68, characters 23-38 Re-raised at file "tests/lib-threads/fileio.ml", line 53, characters 4-149 Called from file "thread.ml", line 131, characters 8-14 cmp: EOF on /tmp/testio2ce820
Being unable to understand why it was failing, I installed OCaml on my system. Now I can compile it directly with the system compiler and run it like:
$ ocamlc -g -w a -vmthread unix.cma threads.cma -I ../testsuite/lib tests/lib-threads/fileio.ml -o program
256-byte chunks, 256-byte chunks
4096-byte chunks, 4096-byte chunks
65536-byte chunks, 65536-byte chunks
256-byte chunks, 4096-byte chunks
4096-byte chunks, 256-byte chunks
4096-byte chunks, 65536-byte chunks
263-byte chunks, 4011-byte chunks
613-byte chunks, 1027-byte chunks
The problem occurs when the thread is reading from the pipe and the resource returns an EAGAIN error and fails when accessed another time.
I've copied the ocaml-4.0.3 directory to a Linux environment, recompiling it and running the testsuite from the freshly compiled version and I've observed the same behavior.
I've found that the difference in behavior is caused by the -nostdlib -I ../stdlib flags. I don't understand why when the compiler uses the stdlib at the default system location the resulting program runs and why it generates an error if I ask the compiler to use the same stdlib file from another directory.
And the program deadlocks when I compile it with:
$ ../byterun/ocamlrun ../ocamlc -g -nostdlib -I /usr/local/lib/ocaml -w a -vmthread -I ../otherlibs/threads -I ../otherlibs/unix unix.cma threads.cma -I ../testsuite/lib tests/lib-threads/fileio.ml -o program
Can someone share some lights on why OCaml is so sensible to stdlib location? Is there a dynamic library failing to load without reporting an error?
Thanks
--
Pierre Métras