Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004229OCamldocumentationpublic2007-03-14 14:322017-06-09 17:18
Reporterfrisch 
Assigned Toshinwell 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionduplicate 
PlatformOSOS Version
Product Version 
Target VersionlaterFixed in Version 
Summary0004229: Casser le typage avec Dynlink
DescriptionDynlink 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.

Dans symtable.ml:

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


Dans interp.c:

    Instruct(SETGLOBAL):
      if (*pc != 0xffff) caml_modify(&Field(caml_global_data, *pc), accu);
      accu = Val_unit;
      pc++;
      Next;
Steps To Reproduceabstract.mli:
type t
val print: t -> unit
val x: t

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

static.ml:
let f = Abstract.print

client.ml:
let () = Static.f Abstract.x

sub/abstract.mli = abstract.ml

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

main.ml:let () =
  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
Tagspatch
Attached Files

- Relationships
related to 0006462resolvedshinwell Dynlinking duplicate module clobbers host program state 
related to 0006957resolvedshinwell Modules name conflict during dynamic loading 
related to 0004231closedlefessan Link multiple casse le système de types 
related to 0004839resolvedshinwell natdynlink reproducible segfault 
related to 0006950resolvedshinwell Dynlink wrong symbol 

-  Notes
(0017859)
shinwell (developer)
2017-06-09 17:18

This has been fixed by https://github.com/ocaml/ocaml/pull/1063 [^] - please continue any discussion there.

- Issue History
Date Modified Username Field Change
2007-03-14 14:32 frisch New Issue
2007-11-10 13:52 xleroy Status new => acknowledged
2009-07-22 09:19 frisch Relationship added child of 0004839
2009-07-22 09:19 frisch Relationship added related to 0004231
2009-07-22 09:19 frisch Relationship deleted child of 0004839
2009-07-22 09:19 frisch Relationship added related to 0004839
2012-07-11 16:11 doligez Target Version => 4.01.0+dev
2012-07-31 13:37 doligez Target Version 4.01.0+dev => 4.00.1+dev
2012-09-14 23:52 doligez Target Version 4.00.1+dev => 4.00.2+dev
2013-07-04 23:10 doligez Target Version 4.00.2+dev => 4.01.0+dev
2013-07-29 15:07 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-31 17:33 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 17:34 doligez Target Version undecided => 4.02.2+dev / +rc1
2015-01-16 22:19 doligez Tag Attached: patch
2015-01-16 22:19 doligez Target Version 4.02.2+dev / +rc1 => 4.02.3+dev
2015-07-15 16:22 doligez Target Version 4.02.3+dev => 4.03.0+dev / +beta1
2015-11-22 11:40 xleroy Relationship added related to 0006950
2016-02-03 12:23 doligez Relationship added related to 0006462
2016-02-03 12:23 doligez Relationship added related to 0006957
2016-02-03 12:25 doligez Target Version 4.03.0+dev / +beta1 => later
2017-02-23 16:35 doligez Category OCaml documentation => Documentation
2017-02-23 16:44 doligez Category Documentation => documentation
2017-02-24 14:53 shinwell Assigned To => shinwell
2017-02-24 14:53 shinwell Status acknowledged => assigned
2017-06-09 17:18 shinwell Note Added: 0017859
2017-06-09 17:18 shinwell Status assigned => resolved
2017-06-09 17:18 shinwell Resolution open => duplicate


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker