Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006427OCamlOCaml typingpublic2014-05-16 19:392014-05-19 12:41
Reporteryallop 
Assigned Togarrigue 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.02.0+dev 
Target VersionFixed in Version4.02.0+dev 
Summary0006427: Soundness bug involving unpacking, functors and abstract module types
DescriptionLeo and I encountered the following problem in the 4.02.0 branch today:

$ cat bug.ml
let flag = ref false
module F(S : sig module type T end) (A : S.T) (B : S.T) =
struct
  module X = (val if !flag then (module A) else (module B) : S.T)
end

module type S = sig type t val x : t end
module Float = struct type t = float let x = 0.0 end
module Int = struct type t = int let x = 0 end

module M = F(struct module type T = S end)

let () = flag := false
module M1 = M(Float)(Int)

let () = flag := true
module M2 = M(Float)(Int)

let _ = [| M2.X.x; M1.X.x |]
$ ocaml bug.ml
Segmentation fault (core dumped)
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0011507)
garrigue (manager)
2014-05-17 03:23

Fixed in 4.02, at revision 14889.

This is a clever way to insert an abstract type in a signature...
How did you find it?
Mtype.contains_type was already checking for abstract module
type definitions, and for unresolved module types, but strangely
ignored this case (probably assumed a bad analogy with type
abbreviations).
(0011521)
yallop (developer)
2014-05-19 12:41

Thanks for the quick fix! This one came up while investigating the boundaries of the module system rather than in a real program. Leo was teaching me how modules work, and I was trying to understand exactly what makes it impossible to write a module with the following type:

   module False : functor (S : sig module type T end) -> S.T

- Issue History
Date Modified Username Field Change
2014-05-16 19:39 yallop New Issue
2014-05-17 03:23 garrigue Note Added: 0011507
2014-05-17 03:23 garrigue Status new => resolved
2014-05-17 03:23 garrigue Fixed in Version => 4.02.0+dev
2014-05-17 03:23 garrigue Resolution open => fixed
2014-05-17 03:23 garrigue Assigned To => garrigue
2014-05-19 12:41 yallop Note Added: 0011521


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker