caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: whitequark <whitequark@whitequark.org>
To: Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: Roberto Di Cosmo <roberto@dicosmo.org>, Leo White <leo@lpw25.net>,
	caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Justifying a breaking 4.03 change, strong dependency  on modules with "external" declarations
Date: Mon, 16 May 2016 02:21:15 +0000	[thread overview]
Message-ID: <883fd5b46c53a93a3313c091f2972af0@whitequark.org> (raw)
In-Reply-To: <CAPFanBE=tev6FqmmVa10fhtNQPPjcU1oUvySjLrsrHmB8nUbZw@mail.gmail.com>

On 2016-05-16 01:09, Gabriel Scherer wrote:
> As Roberto Di Cosmo points out in the thread "parmap package broken in
> opam switch 4.03.0", using an "external" declaration provided by a
> module A now counts as a dependency on A -- in particular, A has to be
> linked in the final executable.
> 
> This breaks some user code (such as Parmap, but I heard reports from
> other breakages) in the case where A was used solely to provide such
> "external" declarations, for C functions implemented in a C stub that
> was linked in the application. In that case it was neither necessary
> nor useful to link A, and projects did not do it. They need to do it
> explicitly now, and break at linking-time otherwise.
> 
> I realize that users may not understand why this change, which looks
> like a regression, happened in 4.03. It is actually a bugfix, see
> PR#4166 ( http://caml.inria.fr/mantis/view.php?id=4166 ): if A does
> not only provide those external declarations, but also initializes
> some state that the C functions rely on (such as exception
> declarations), then forgetting to link A may result in a crash at
> runtime.
> 
> In other words, the pre-4.03 situation could result in some rare cases
> of user error in a very subtle, very difficult to understand bug.

I am highly fond of this change. This was a substantial problem with
the LLVM OCaml bindings--I as well as other contributors have introduced
a bug more than once, but even beyond that, not having the `external`
declarations in the .mli unnecessarily pessimizes some hot paths.

-- 
whitequark

      reply	other threads:[~2016-05-16  2:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-16  1:09 [Caml-list] Justifying a breaking 4.03 change, strong dependency on modules with "external" declarations (was: ) Gabriel Scherer
2016-05-16  2:21 ` whitequark [this message]

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=883fd5b46c53a93a3313c091f2972af0@whitequark.org \
    --to=whitequark@whitequark.org \
    --cc=caml-list@inria.fr \
    --cc=gabriel.scherer@gmail.com \
    --cc=leo@lpw25.net \
    --cc=roberto@dicosmo.org \
    /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).