Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0003984OCamlOCaml generalpublic2006-03-04 16:332015-09-09 11:28
Reportermwahab 
Assigned Togarrigue 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version3.09.1 
Target Version4.03.0+devFixed in Version 
Summary0003984: Compiler ignores types in .cmi file [problems with #trace]
DescriptionThe OCaml compiler (ocamlc) seems to ignore the function declarations
in .cmi files, allowing wrongly typed expressions. This bug was
discovered when using #trace where it lead to a segmentation violation.

Files attached (in ocamlbug.tar): test.mli, test.ml and script.ml.
Compile test.mli then test.ml:
ocamlc -c test.mli
ocamlc -c test.ml

Run the script:
ocaml script.ml

The compiler should fail on test.ml but doesn't and running the script
leads to a segfault.

Additional InformationThe system used is OCaml version 3.09.1 on Linux-x86.
TagsNo tags attached.
Attached Filestar file icon ocamlbug.tar [^] (10,240 bytes) 2006-03-04 16:33

- Relationships

-  Notes
(0003586)
Christophe (reporter)
2006-03-05 09:18

This is not a bug of ocamlc. The mli file constraints the types outside of the module, not inside !
In your example, the type of log is
val log : 'a -> 'b -> unit
inside module test, but outside it is what you wrote in test.mli

The only bug is in the directive #trace that follows the public type not the private....
It can be seen with simpler examples :

# module T: sig val f : int -> unit val g: 'a -> unit end = struct let f x = ignore x let g x = f x end;;
module T : sig val f : int -> unit val g : 'a -> unit end
# #trace T.f;;
T.f is now traced.
# T.g 'a';;
T.f <-- 97
T.f --> ()
- : unit = ()

Of course, it must not do a seg fault when printing some "impossible value" (so there is something to be fixed (?), even if it does not crach on most example, but if you use string instead of int in the simple example, it crashes because it does not verify that the "string" is well formed... )
I am not sure it must be fixed (it seems using #trace is like using module Obj.... it must be done with careful knowledge)
(0014428)
garrigue (manager)
2015-09-09 11:27

As pointed out there is nothing wrong in the semantics.
The segmentation fault in #trace would of course be a bug, but it seems that it has been fixed long ago.

- Issue History
Date Modified Username Field Change
2006-03-04 16:33 mwahab New Issue
2006-03-04 16:33 mwahab File Added: ocamlbug.tar
2006-03-05 09:18 Christophe Note Added: 0003586
2006-03-29 16:23 doligez Severity minor => tweak
2006-03-29 16:23 doligez Status new => acknowledged
2006-03-29 16:23 doligez Summary Compiler ignores types in .cmi file => Compiler ignores types in .cmi file [problems with #trace]
2006-03-29 16:23 doligez Description Updated
2006-03-29 16:23 doligez Additional Information Updated
2006-03-29 16:42 doligez Category Incoming => OCaml general
2012-09-06 16:43 doligez Target Version => 4.00.1+dev
2012-09-11 14:47 doligez Target Version 4.00.1+dev => 4.01.0+dev
2013-07-24 11:52 doligez Target Version 4.01.0+dev => 4.01.1+dev
2014-05-25 20:20 doligez Target Version 4.01.1+dev => 4.02.0+dev
2014-07-16 20:59 doligez Target Version 4.02.0+dev => 4.02.1+dev
2014-07-16 21:00 doligez Target Version 4.02.1+dev => 4.02.0+dev
2014-07-21 18:02 doligez Severity tweak => minor
2014-07-21 18:02 doligez Status acknowledged => confirmed
2014-07-21 18:02 doligez Target Version 4.02.0+dev => 4.02.1+dev
2014-09-04 00:25 doligez Target Version 4.02.1+dev => undecided
2014-09-25 16:29 doligez Target Version undecided => 4.02.2+dev / +rc1
2015-02-24 23:35 doligez Target Version 4.02.2+dev / +rc1 => 4.02.3+dev
2015-07-15 16:26 doligez Target Version 4.02.3+dev => 4.03.0+dev
2015-09-09 11:27 garrigue Note Added: 0014428
2015-09-09 11:27 garrigue Status confirmed => resolved
2015-09-09 11:27 garrigue Resolution open => fixed
2015-09-09 11:27 garrigue Assigned To => garrigue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker