You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 5473 Reporter:@alainfrisch Status: confirmed (set by @xavierleroy on 2012-01-17T14:52:31Z) Resolution: open Priority: low Severity: minor Category: compiler driver Related to:#3488#4231 Monitored by:@hcarty
Bug description
The 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 reproduce
abstract.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
I'm not completely sure, but it is possible the recent work on functor packs (which has involved some more fundamental work on the packing system) might help here.
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.
Original bug ID: 5473
Reporter: @alainfrisch
Status: confirmed (set by @xavierleroy on 2012-01-17T14:52:31Z)
Resolution: open
Priority: low
Severity: minor
Category: compiler driver
Related to: #3488 #4231
Monitored by: @hcarty
Bug description
The 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 reproduce
abstract.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
The text was updated successfully, but these errors were encountered: