Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Markus Mottl <markus.mottl@gmail.com>
To: Xavier Leroy <Xavier.Leroy@inria.fr>
Cc: OCaml List <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Custom blocks and finalization
Date: Fri, 8 May 2009 09:48:21 -0400	[thread overview]
Message-ID: <f8560b80905080648p5d01c5bdjcf9f4cbcb92df399@mail.gmail.com> (raw)
In-Reply-To: <4A03FD30.6020307@inria.fr>

On Fri, May 8, 2009 at 05:36, Xavier Leroy <Xavier.Leroy@inria.fr> wrote:
> I foresee absolutely no problems with registering/unregistering global
> roots from a C finalizer.  As the manual states, the big no-no in
> C functions attached to custom blocks is allocating in the heap,
> either directly or via a callback into Caml or by releasing the global
> lock.  Within a finalizer, you should also refrain from raising an
> exception, as this would leave the GC is a bizarre state.  But global
> roots operations are OK.

Thanks, good to know.  I had only taken a superficial look at the
implementation and didn't see any problem with global roots, but even
if this might be true now, I wasn't sure whether this would remain so
in the future.

> As for not using the CAMLparam, etc macros in these functions: since
> these functions must not allocate, the macros are certainly not
> needed.  I don't think that actually using them could cause a problem,
> but that would be silly anyway, so don't use them in this context.

Right, since allocations are prohibited anyway, one doesn't need to
protect the passed value and won't need local roots.  I guess the
documentation could still be clarified in this respect, because the
explicit prohibition of using the local root (de)registration
functions suggests that these operations are not guaranteed to be
sound and that this might also extend to global roots.

Regards,
Markus

-- 
Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com


      reply	other threads:[~2009-05-08 13:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-30 15:46 Markus Mottl
2009-04-30 18:17 ` [Caml-list] " Dr. Thomas Fischbacher
     [not found] ` <49FB04A9.3090008@soton.ac.uk>
2009-05-01 16:00   ` Markus Mottl
2009-05-06 16:30     ` Dr. Thomas Fischbacher
2009-05-06 16:54       ` Markus Mottl
2009-05-06 17:53         ` Dr. Thomas Fischbacher
2009-05-08  9:36         ` Xavier Leroy
2009-05-08 13:48           ` Markus Mottl [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=f8560b80905080648p5d01c5bdjcf9f4cbcb92df399@mail.gmail.com \
    --to=markus.mottl@gmail.com \
    --cc=Xavier.Leroy@inria.fr \
    --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