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
value access to extensible variant tag binds module value instead (name clash) #7563
Comments
Comment author: @gasche Thanks for the report! The bug was introduced by module aliases in 4.02. Two ways to make the reproduction case simpler are:
The following patch fixes the issue, but I am not sure that it is correct overall. diff --git a/bytecomp/lambda.ml b/bytecomp/lambda.ml let transl_path ?(loc=Location.none) env path =
(* Compile a sequence of expressions *) |
Comment author: @yallop For full dramatic effect, here's a way to turn the bug into a segmentation fault: $ ocaml module M = struct
module M : sig module X = List exception X end print_endline (Printexc.to_string M.X);;Segmentation fault |
Comment author: @gasche Reporter: I am about to write a Changes entry, what is the name that should be used for crediting the report? Are you Manuel Fähndrich or Manuel Fahndrich? (Is it correct to assume that the first version is actually the correct one, despite the second one occurring more often on the internet?). If not, what name should be used to credit your work? |
Comment author: fahndrich I'm the same person. Do I have 2 accounts? I dropped the umlaut a long time ago when I went to the US. I only use it in LaTeX papers :-) |
Comment author: @gasche Well, googling for "site:caml.inria.fr/mantis fahndirch" only reported issues from way back, submitted also using your first name, so I preferred to ask than just assume. Thanks! |
Original bug ID: 7563
Reporter: fahndrich
Assigned to: @gasche
Status: resolved (set by @gasche on 2017-06-26T15:21:01Z)
Resolution: fixed
Priority: normal
Severity: major
Platform: x86
OS: Linux
OS Version: Linux-gnu Centos
Version: 4.03.0
Fixed in version: 4.06.0 +dev/beta1/beta2/rc1
Category: middle end (typedtree to clambda)
Monitored by: @gasche
Bug description
A reference from a module A to B picks up B.C (a module value) instead of B.C an extensible variant tag.
This results in a block with tag 0 containing the module values being passed around instead of an extensible variant value.
Repro is attached.
Steps to reproduce
ocamlopt a_module.ml debug.ml variant.ml repro.ml -o repro
./repro
Prints:
Stored: a Clash
Direct: unknown: tag: 0, Size 3
0: An int 0
1: tag: 247, Size 2
0: <unknown with tag 1001>
1: An int 1
2: tag: 247, Size 2
0: <unknown with tag 1001>
1: An int 1
Fatal error: exception Invalid_argument("compare: functional value")
The first print is getting the right variant value by accessing it via another name.
The second print is getting the wrong module value and I added some debug output to show the contents. As you can see the contents corresponds to the a_module contents (an int (empty list), and 2 closures).
The fatal error is trying to compare the ill-bound variant tag (which is really a module) and causing comparison of closures.
Additional information
Tested on 4.02.3, 4.03.0, 4.04.1, and 4.06.0+trunk and it fails in all cases.
(My category above is just a guess, middle end)
File attachments
The text was updated successfully, but these errors were encountered: