Skip to content
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

Casser le typage avec Dynlink #4229

vicuna opened this issue Mar 14, 2007 · 1 comment


Copy link

commented Mar 14, 2007

Original bug ID: 4229
Reporter: @alainfrisch
Assigned to: @mshinwell
Status: resolved (set by @mshinwell on 2017-06-09T15:18:46Z)
Resolution: duplicate
Priority: normal
Severity: minor
Target version: later
Category: documentation
Tags: patch
Related to: #4231 #4839 #6462 #6950 #6957
Monitored by: @glondu jmeber "Julien Signoles" monate @dbuenzli @Chris00 ertai

Bug description

Dynlink autorise à charger un module déjà présent dans le programme principal ou déjà dynlinké avant (si sa signature est la même). En particulier, cela permet de redéfinir l'implémentation d'un type abstrait et donc de casser le typage. Certes, il faut vraiment le chercher (cf plus bas).

Une solution un peu moche consisterait à empecher de cacher un symbole global.


let slot_for_setglobal id =
if Tbl.mem id !global_table.num_tbl then 0xffff
else enter_numtable global_table id

Dans interp.c:

  if (*pc != 0xffff) caml_modify(&Field(caml_global_data, *pc), accu);
  accu = Val_unit;

Steps to reproduce

type t
val print: t -> unit
val x: t
type t = int
let print i = Printf.printf "Abstract %i\n" i
let x = 10
let f = Abstract.print
let () = Static.f Abstract.x

sub/abstract.mli =

type t = string
let print i = Printf.printf "Abstract %s\n" i
let x = "foo" () =
Dynlink.init ();
Dynlink.loadfile "client.cmo"; (* utilise abstract.cmo )
Dynlink.loadfile "sub/abstract.cmo";
Dynlink.loadfile "client.cmo" (
utilise sub/abstract.cmo *)

On compile tout ça...

$ ocamlc -o main dynlink.cma abstract.cmo static.cmo main.cmo
$ ./main
Abstract 10
Abstract 67345600


This comment has been minimized.

Copy link

commented Jun 9, 2017

Comment author: @mshinwell

This has been fixed by #1063 - please continue any discussion there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.