caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* linking the same module more than once
@ 2008-08-07 23:23 Jake Donham
  2008-08-08  0:13 ` [Caml-list] " Stéphane Glondu
  2008-08-08  6:13 ` Alain Frisch
  0 siblings, 2 replies; 4+ messages in thread
From: Jake Donham @ 2008-08-07 23:23 UTC (permalink / raw)
  To: caml-list

Hi,

Consider the following code:

  a.ml: let a () = raise (Unix.Unix_error (Unix.E2BIG, "", ""))
  b.ml: try A.a () with Unix.Unix_error (_,_,_) -> ()

compiled with

  ocamlc -o test unix.cma a.ml unix.cma b.ml

Run it:

  > ./test
  Fatal error: exception Unix.Unix_error(0, "", "")

With exceptions raised from C code this can even happen within the same module:

  a.ml: let a () = try Unix.mkdir "/tmp" 0o777 with Unix.Unix_error
(_,_,_) -> ()
  b.ml: A.a ()

There is no trouble linking a module more than once, but different
parts of the code can wind up linked to different instances of the
module, leading to the confusing behavior that exception handling
seems not to work (and generally that things you think are equal are
not). For exceptions raised from C code, since
Callback.register_exception is called twice, the C code has a
different instance from the ML code.

Ocamlopt catches multiple definitions; seems like ocamlc should also.
But I see bugs

  http://caml.inria.fr/mantis/view.php?id=1522
  http://caml.inria.fr/mantis/view.php?id=1657

suggesting that this is expected behavior. Is there some use for it?

(I ran into this trying to use the ocaml-ssl module, which for some
reason builds unix.cma into ssl.cma.)

Jake


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-08-08 16:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-07 23:23 linking the same module more than once Jake Donham
2008-08-08  0:13 ` [Caml-list] " Stéphane Glondu
2008-08-08  6:13 ` Alain Frisch
2008-08-08 16:28   ` Jake Donham

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).