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

ocamldep 4.04.0+beta2+flambda segfault when building base #7370

Closed
vicuna opened this issue Sep 23, 2016 · 4 comments
Closed

ocamldep 4.04.0+beta2+flambda segfault when building base #7370

vicuna opened this issue Sep 23, 2016 · 4 comments
Assignees
Milestone

Comments

@vicuna
Copy link

vicuna commented Sep 23, 2016

Original bug ID: 7370
Reporter: @edwintorok
Assigned to: @damiendoligez
Status: closed (set by @damiendoligez on 2016-11-02T14:21:17Z)
Resolution: fixed
Priority: normal
Severity: minor
Platform: x86-64
OS: Linux
OS Version: Gentoo
Target version: 4.04.0 +dev / +beta1 / +beta2
Fixed in version: 4.04.0 +dev / +beta1 / +beta2
Category: tools (ocaml{lex,yacc,dep,debug,...})
Tags: github
Monitored by: @gasche @diml

Bug description

I tried to build janestreet/base with 4.04.0+beta2+flambda (ocamldoc in 4.03 doesn't obey -open, and I wanted to generate some docs), but ocamldep crashed:

[52483.186853] ocamldep[20351]: segfault at c00 ip 000000000040afd7 sp 00007fff5b528f80 error 4 in ocamldep.opt[400000+f5000]

Steps to reproduce

$ curl -L -o avltree.ml 'https://github.com/janestreet/base/blob/01cd6e6e0b13aa80e872f1fd90799a2f083c9ab9/bootstrap/src/avltree.ml?raw=true'
$ ocamldep avltree.ml
Segmentation fault
$ ocamldep -version
ocamldep, version 4.04.0+beta2
$ ocamlc -config
version: 4.04.0+beta2
standard_library_default: /home/edwin/.opam/4.04.0+beta2+flambda/lib/ocaml
standard_library: /home/edwin/.opam/4.04.0+beta2+flambda/lib/ocaml
standard_runtime: /home/edwin/.opam/4.04.0+beta2+flambda/bin/ocamlrun
ccomp_type: cc
bytecomp_c_compiler: gcc -std=gnu99 -O2 -fno-strict-aliasing -fwrapv -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -fPIC
bytecomp_c_libraries: -lm -ldl -lcurses -lpthread
native_c_compiler: gcc -std=gnu99 -O2 -fno-strict-aliasing -fwrapv -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT
native_c_libraries: -lm -ldl
native_pack_linker: ld -r -o
ranlib: ranlib
cc_profile: -pg
architecture: amd64
model: default
system: linux
asm: as
asm_cfi_supported: true
with_frame_pointers: false
ext_obj: .o
ext_asm: .s
ext_lib: .a
ext_dll: .so
os_type: Unix
default_executable_name: a.out
systhread_supported: true
host: x86_64-unknown-linux-gnu
target: x86_64-unknown-linux-gnu
flambda: true
spacetime: false
exec_magic_number: Caml1999X011
cmi_magic_number: Caml1999I021
cmo_magic_number: Caml1999O011
cma_magic_number: Caml1999A012
cmx_magic_number: Caml1999Y016
cmxa_magic_number: Caml1999Z015
ast_impl_magic_number: Caml1999M019
ast_intf_magic_number: Caml1999N018
cmxs_magic_number: Caml2007D002
cmt_magic_number: Caml2012T008

Additional information

Older versions of the compiler reject the file instead of crashing:

~/.opam/4.02.3/bin/ocamldep avltree.ml

Fatal error: OCaml and preprocessor have incompatible versions
Fatal error: exception Misc.Fatal_error
~/.opam/3.12.1/bin/ocamldep avltree.ml
Fatal error: exception Failure("Ocaml and preprocessor have incompatible versions")

Stacktrace with 4.04:
(gdb) r
Starting program: /home/edwin/.opam/4.04.0+beta2+flambda/bin/ocamldep avltree.ml

Program received signal SIGSEGV, Segmentation fault.
0x000000000040afd7 in camlDepend__add_expr_886 () at parsing/depend.ml:212
212 parsing/depend.ml: No such file or directory.
(gdb) bt
#0 0x000000000040afd7 in camlDepend__add_expr_886 () at parsing/depend.ml:212
#1 0x0000000000465b61 in camlList__iter_346 () at list.ml:77
#2 0x0000000000465b61 in camlList__iter_346 () at list.ml:77
#3 0x000000000040b7e5 in camlDepend__add_bindings_889 () at parsing/depend.ml:286
#4 0x000000000040b013 in camlDepend__add_expr_886 () at parsing/depend.ml:217
#5 0x0000000000465b61 in camlList__iter_346 () at list.ml:77
#6 0x000000000040b7e5 in camlDepend__add_bindings_889 () at parsing/depend.ml:286
#7 0x000000000040c443 in camlDepend__add_struct_item_900 () at parsing/depend.ml:427
#8 0x0000000000465c48 in camlList__fold_left_389 () at list.ml:88
#9 0x000000000040c319 in camlDepend__add_structure_898 () at parsing/depend.ml:415
#10 0x000000000040ca81 in camlDepend__add_implementation_902 () at parsing/depend.ml:478
#11 0x0000000000406732 in camlOcamldep__read_parse_and_extract_1419 ()
#12 0x0000000000406d1c in camlOcamldep__ml_file_dependencies_1748 ()
#13 0x0000000000407063 in camlOcamldep__process_file_as_1835 ()
#14 0x000000000049111f in camlArg__parse_argv_dynamic_inner_476 () at arg.ml:247
#15 0x0000000000492b49 in camlArg__parse_1143 () at arg.ml:254
#16 0x0000000000408805 in camlOcamldep__entry ()
#17 0x0000000000402479 in caml_program ()
#18 0x00000000004bf3c6 in caml_start_program ()
#19 0x00000000004bfa0d in caml_main (argv=0x7fffffffd4f8) at startup.c:145
#20 0x000000000040200c in main (argc=, argv=) at main.c:37

Should a magic number be bumped somewhere in 4.04 to make it reject this file?

@vicuna
Copy link
Author

vicuna commented Oct 26, 2016

Comment author: @damiendoligez

Indeed, commit 43f90e9 should have bumped the magic number.

@vicuna
Copy link
Author

vicuna commented Oct 26, 2016

Comment author: @gasche

Is there a way the CI could catch the mistake of not bumping the magic number when it should?

@vicuna
Copy link
Author

vicuna commented Oct 27, 2016

Comment author: @damiendoligez

For this magic number, probably, but you'll need a binary AST file that exercises all the features of the AST.
For other magic numbers, it's really not obvious.

@vicuna
Copy link
Author

vicuna commented Oct 27, 2016

Comment author: @damiendoligez

See #877 ( #877 ).

@vicuna vicuna closed this as completed Nov 2, 2016
@vicuna vicuna added the tools label Mar 14, 2019
@vicuna vicuna added this to the 4.04.0 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants