Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005473OCamlOCaml generalpublic2012-01-12 10:322014-05-25 20:20
Reporterfrisch 
Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusconfirmedResolutionopen 
PlatformOSOS Version
Product Version 
Target Version4.02.0+devFixed in Version 
Summary0005473: Double linking of native modules (with -pack)
DescriptionThe code below allows us to link several modules with the same name and thus break the type system (-> segfault).

Proposal: -pack should fail if one the packed modules depends on the .cmi of a module which is itself not part of the package to be created, and whose signature refers to one the packed modules. In the example: the packed x.cmo depends on the non-packed api.cmi, whose signature mentions Abstract, which itself is part of the package. This creates an opportunity for shadowing Abstract with a different module outside the package.
Steps To Reproduceabstract.mli = sub/abstract.mli:
type t
val x: t
val f: t -> unit

abstract.ml:
type t = int
let x = 10
let f x = Printf.printf "Abstract 1 : %i\n" x

sub/abstract.ml:
type t = string
let x = "foo"
let f x = Printf.printf "Abstract 2 : %s\n" x

api.ml:
let r : Abstract.t list ref = ref []

x.ml = sub/x.ml:
let () = Api.r := Abstract.x :: !Api.r; List.iter Abstract.f !Api.r


compilation:
$ ocamlopt -c abstract.mli abstract.ml api.ml x.ml
$ cd sub
$ ocamlopt -c -for-pack P -I .. x.ml
$ ocamlopt -c -for-pack P -I .. abstract.mli
$ ocamlopt -c -for-pack P -I .. abstract.ml
$ ocamlopt -pack -o p.cmx abstract.cmx x.cmx
$ cd ..
$ ocamlopt -o main api.cmx abstract.cmx x.cmx sub/p.cmx
$ ./main
zsh: segmentation fault ./main
TagsNo tags attached.
Attached Files

- Relationships
related to 0004231closedlefessan Link multiple casse le système de types 

-  Notes
There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2012-01-12 10:32 frisch New Issue
2012-01-12 10:33 frisch Relationship added related to 0004231
2012-01-17 15:52 xleroy Status new => confirmed
2012-07-10 11:43 doligez Target Version => 4.01.0+dev
2012-07-31 13:36 doligez Target Version 4.01.0+dev => 4.00.1+dev
2012-09-20 18:14 doligez Target Version 4.00.1+dev => 4.01.0+dev
2013-08-12 16:26 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


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker