caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Jake Donham" <jake@donham.org>
To: caml-list@yquem.inria.fr
Subject: linking the same module more than once
Date: Thu, 7 Aug 2008 16:23:01 -0700	[thread overview]
Message-ID: <c7e4e9f0808071623r61cad81cya5fd55f57352a720@mail.gmail.com> (raw)

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


             reply	other threads:[~2008-08-07 23:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-07 23:23 Jake Donham [this message]
2008-08-08  0:13 ` [Caml-list] " Stéphane Glondu
2008-08-08  6:13 ` Alain Frisch
2008-08-08 16:28   ` Jake Donham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c7e4e9f0808071623r61cad81cya5fd55f57352a720@mail.gmail.com \
    --to=jake@donham.org \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).