samoht / assemblage

A collection of tools to manage the configuration of OCaml projects
54 stars 4 forks source link

Segmentation fault callling OCaml 4.02 #122

Open smondet opened 9 years ago

smondet commented 9 years ago

Maybe this is an OCaml bug.

Still with this: https://github.com/smondet/atd2cconv When switching to OCaml 4.02.0:

 $ make clean; make
rm -f *~ **/*~
rm -rf _build
all => lib bin
bin-atd2cconv             <= prepare bin-atd2cconv
main.ml                   <= prepare unit-main-bin-atd2cconv
main.cml-byte             <= pp-byte unit-main-bin-atd2cconv
lib-atd2cconv             <= prepare lib-atd2cconv
atd2cconv.ml              <= prepare unit-atd2cconv-lib-atd2cconv
atd2cconv.mli             <= prepare unit-atd2cconv-lib-atd2cconv
main.ml.d                 <= dep unit-main-bin-atd2cconv
/bin/sh: line 1: 75164 Segmentation fault: 11  ocamldep.opt -I _build/bin-atd2cconv -I _build/lib-atd2cconv -impl _build/bin-atd2cconv/main.cml-byte > _build/bin-atd2cconv/main.ml.d
atd2cconv.cmli-byte       <= pp-byte unit-atd2cconv-lib-atd2cconv
atd2cconv.mli.d           <= dep unit-atd2cconv-lib-atd2cconv
atd2cconv.cml-byte        <= pp-byte unit-atd2cconv-lib-atd2cconv
atd2cconv.ml.d            <= dep unit-atd2cconv-lib-atd2cconv
/bin/sh: line 1: 75176 Segmentation fault: 11  ocamldep.opt -I _build/lib-atd2cconv -impl _build/lib-atd2cconv/atd2cconv.cml-byte > _build/lib-atd2cconv/atd2cconv.ml.d
atd2cconv.cmi             <= compile-byte unit-atd2cconv-lib-atd2cconv
make[1]: *** [_build/lib-atd2cconv/atd2cconv.cmi] Segmentation fault: 11
make: *** [all] Error 2

The command that fails (run by the generated Makefile) is:

ocamlc.opt -c -g -bin-annot -I /Users/sebastienmondet/.opam/4.02.0/lib/easy-format -I /Users/sebastienmondet/.opam/4.02.0/lib/atd -I /Users/sebastienmondet/.opam/4.02.0/lib/nonstd -I /Users/sebastienmondet/.opam/4.02.0/lib/smart_print -I _build/lib-atd2cconv -intf _build/lib-atd2cconv/atd2cconv.cmli-byte

The marchalled file looks like:

 $ xxd _build/lib-atd2cconv/atd2cconv.cmli-byte 
0000000: 4361 6d6c 3139 3939 4e30 3135 8495 a6be  Caml1999N015....
0000010: 0000 0024 0000 0001 0000 000a 0000 0006  ...$............
0000020: 0922 5f62 7569 6c64 2f6c 6962 2d61 7464  ."_build/lib-atd
0000030: 3263 636f 6e76 2f61 7464 3263 636f 6e76  2cconv/atd2cconv
0000040: 2e6d 6c69 8495 a6be 0000 0134 0000 0046  .mli.......4...F
0000050: 0000 0108 0000 00fa a0a0 a0a0 3574 7261  ............5tra
0000060: 6e73 666f 726d 5f6d 6f64 756c 655f 6974  nsform_module_it
0000070: 656d b0c0 0922 5f62 7569 6c64 2f6c 6962  em..."_build/lib
0000080: 2d61 7464 3263 636f 6e76 2f61 7464 3263  -atd2cconv/atd2c
0000090: 636f 6e76 2e6d 6c69 4241 45c0 0402 4241  conv.mliBAE...BA
00000a0: 5a40 b0a0 b120 a0a3 a0a1 9027 4174 645f  Z@... .....'Atd_
00000b0: 6173 742b 6d6f 6475 6c65 5f69 7465 6db0  ast+module_item.
00000c0: c004 0f42 415c c004 1042 416f 4040 b004  ...BA\...BAo@@..
00000d0: 0304 0240 a0b7 a0b0 224f 6b40 a0a0 a3a0  ...@...."Ok@....
00000e0: a190 2a53 6d61 7274 5072 696e 7421 74b0  ..*SmartPrint!t.
00000f0: c004 2043 737e c004 2143 7300 4a40 40b0  .. Cs~..!Cs.J@@.
0000100: 0403 0402 4040 a0b0 2545 7272 6f72 40a0  ....@@..%Error@.
0000110: a0b7 a0b0 2f4e 6f74 5f69 6d70 6c65 6d65  ..../Not_impleme
0000120: 6e74 6564 40a0 a0a3 a090 2673 7472 696e  nted@.....&strin
0000130: 67b0 c004 3344 004b 0070 c004 3444 004b  g...3D.K.p..4D.K
0000140: 0076 4040 b004 0304 0240 4040 4040 b0c0  .v@@.....@@@@@..
0000150: 0437 4400 4b00 59c0 0438 4400 4b00 7840  .7D.K.Y..8D.K.x@
0000160: 4040 4140 b0c0 043a 4373 75c0 043b 4400  @@A@...:Csu..;D.
0000170: 4b00 7940 b004 2e04 0240 40b0 c004 3e42  K.y@.....@@...>B
0000180: 4141 0404 40b0 0402 0405 4040            AA..@.....@@

Replacing atd2cconv.cmli-byte with atd2cconv.mli makes the command work, and the next one fails in the same way (the cml-byte, and then the cml-native, etc...).

smondet commented 9 years ago

Also inside opam the error is different but seems also related to marshalling:

Fatal error: exception Invalid_argument("output_value: functional value")

(from there: https://travis-ci.org/hammerlab/ketrew/jobs/36071380)

smondet commented 9 years ago

The difference between with and without opam, was the version ocaml-dumpast used.

With the “right” one, the error is:

Fatal error: exception Invalid_argument("output_value: functional value")
sanmai-NL commented 9 years ago

I cannot build the hello world example:

do nov 13 21:23:36 UTC 2014   sander@s1:/home/sander/devel/hello/                                  
        # assemblage describe
==> Loading assemble.ml 

==> hello version-not-set
└─┬─ bin-hello
  └─ main.ml                                   
do nov 13 21:25:15 UTC 2014   sander@s1:/home/sander/devel/sopp/hello/                                  
        # assemblage setup
==> Loading assemble.ml 

==> hello version-not-set
==> write Makefile
==> skip  META
==> write hello.install
==> write .merlin
do nov 13 21:25:41 UTC 2014   sander@s1:/home/sander/devel/hello/                                  
        # make install
bin-hello                 <= prepare bin-hello
main.ml                   <= prepare unit-main-bin-hello
main.cml-byte             <= pp-byte unit-main-bin-hello
Fatal error: exception Invalid_argument("output_value: functional value")
all => bin
make[1]: Entering directory '/home/sander/devel/sopp/hello'
main.ml.d                 <= dep unit-main-bin-hello
Fatal error: exception End_of_file
make[1]: *** No rule to make target '_build/bin-hello/main.ml.d', needed by '_build/bin-hello/main.cmo'.  Stop.
make[1]: Leaving directory '/home/sander/devel/sopp/hello'
Makefile:118: recipe for target 'all' failed
make: *** [all] Error 2

My environment:

        # ocaml -version
The OCaml toplevel, version 4.02.1

        # opam --version
1.2.0

        # opam info assemblage
             package: assemblage
             version: ~unknown
              pinned: git (a3d7e4be)
        upstream-url: /opt/installers/assemblage
       upstream-kind: git
              author: Thomas Gazagnaire <thomas@gazagnaire.org>, Daniel Bünzli <daniel.buenzli i@erratique.ch>
             license: ISC
             depends: cmdliner & dumpast
   installed-version: ~unknown [4.02.1]
   available-version: ~unknown
         description:
samoht commented 9 years ago

I guess this is an issue with ocaml-dump. Might need some porting to the latest release of OCaml.