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

-annot option causes segfault #6149

Closed
vicuna opened this issue Aug 30, 2013 · 7 comments
Closed

-annot option causes segfault #6149

vicuna opened this issue Aug 30, 2013 · 7 comments
Labels
Milestone

Comments

@vicuna
Copy link

vicuna commented Aug 30, 2013

Original bug ID: 6149
Reporter: @bobzhang
Status: closed (set by @damiendoligez on 2015-02-26T15:44:32Z)
Resolution: not a bug
Priority: normal
Severity: minor
Version: 4.01.0+dev
Target version: 4.02.2+dev / +rc1
Category: ~DO NOT USE (was: OCaml general)
Parent of: #5961
Monitored by: @gasche

Bug description

This is hard to produce since it's based on a preprocessor.
What I observed:

_build>ocamlc.opt -w +a-4-32-30 -c -w -41 -pp 'boot/fan -printer p' -I src -I common -o src/stdFan.cmo src/stdFan.ml
File "src/stdFan.ml", line 6, characters 0-11:
Warning 33: unused open Format.
_build> ocamlc.opt -annot -w +a-4-32-30 -c -w -41 -pp 'boot/fan -printer p' -I src -I common -o src/stdFan.cmo src/stdFan.ml
File "src/stdFan.ml", line 6, characters 0-11:
Warning 33: unused open Format.
Segmentation fault: 11

_build>ocamlc.opt -v
The OCaml compiler, version 4.01.0+dev22-2013-08-20
Standard library directory: /Users/bobzhang/.opam/4.01.0dev+trunk/lib/ocaml

File attachments

@vicuna
Copy link
Author

vicuna commented Aug 30, 2013

Comment author: @bobzhang

Since the source file does not make sense, I uploaded a marshalized ast

_build> ocamlc.opt -annot -w +a-4-32-30 -c -w -41 -o src/stdFan.cmo marshal_ast.ml
File "src/stdFan.ml", line 6, characters 0-11:
Warning 33: unused open Format.
Segmentation fault: 11
_build> ocamlc.opt -w +a-4-32-30 -c -w -41 -o src/stdFan.cmo marshal_ast.ml
File "src/stdFan.ml", line 6, characters 0-11:
Warning 33: unused open Format.

@vicuna
Copy link
Author

vicuna commented Aug 30, 2013

Comment author: @bobzhang

It seems to be the location problem

@vicuna
Copy link
Author

vicuna commented Aug 30, 2013

Comment author: @alainfrisch

Can you elaborate? Issue #5961 gave a proper assert failure, not a segfault.

@vicuna
Copy link
Author

vicuna commented Aug 30, 2013

Comment author: @bobzhang

Can you reproduce this behavior on your machine?
I tried ocamlc.opt -annot stdFan_ppo.ml, it works fine.

My experimentation:
First, I exported annotations in typing/stypes.ml

Running the following scripts

let f file =
Pparse.file Format.std_formatter file Parse.implementation Config.ast_impl_magic_number;;

let file = "/Users/bobzhang/fan/_build/marshal_ast1.ml"
let a = f file

let env = Compmisc.initial_env()

let _ = begin

Clflags.annotations := true;
Typemod.type_implementation "t.ml" "t" "T" env a;
Clflags.annotations := false;
(* Stypes.dump None; *)
end

so far so good, then I access Stypes.annotations in the toplevel, which gives me a segfault.
List.length !Stypes.annotation ==> 2

let v = Obj.repr (List.nth !Stypes.annotations 0);;
val v : Obj.t =

Marshal.to_channel ochan v [];;

Exception: Invalid_argument "output_value: functional value".

@vicuna
Copy link
Author

vicuna commented Aug 30, 2013

Comment author: @bobzhang

It seems like Stypes.record is corrupted, but it's not obvious to me

@vicuna
Copy link
Author

vicuna commented Sep 2, 2013

Comment author: @damiendoligez

I have reproduced the behaviour on my machine with this command line:
ocamlc -annot -c marshal_ast.ml

@vicuna
Copy link
Author

vicuna commented Feb 26, 2015

Comment author: @damiendoligez

Your AST file is not correctly formed. As you can see in the dump I've attached, it contains two Pexp_function constructors (lines 237 and 244), each with one element in its (pattern * expression) list. In both patterns (lines 241 and 248) the ppat_loc field is incorrect: instead of a Location.t, it's a Lexing.position.

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

1 participant