caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: ygrek <ygrek@autistici.org>
To: Christophe Raffalli <christophe@raffalli.eu>
Cc: Xavier Leroy <Xavier.Leroy@inria.fr>, caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Global roots
Date: Mon, 21 Dec 2020 15:32:13 -0700	[thread overview]
Message-ID: <20201221153213.1844759e@autistici.org> (raw)
In-Reply-To: <X+ENpGYozJ31RJui@oulala>

On Mon, 21 Dec 2020 22:03:32 +0100
Christophe Raffalli <christophe@raffalli.eu> wrote:

> static void protect_callback(char *name, value f, value v1)
> {
>   caml_acquire_runtime_system();
>   {
>     CAMLparam2(f,v1);
>     CAMLlocal1(res);
>     res = caml_callback_exn(f, v1);
>     if(Is_exception_result(res))
>       fprintf(stderr, "Egl.main_loop: "
> 	      "WARNING: %s raised an exception\n", name) ;
>     CAMLdrop;
>   }
>   caml_release_runtime_system();
> }

Values pointed by f and v1 may be moved by gc prior to caml_acquire_runtime_system call, but the values passed to the function (in registers or via stack)
will be pointing to old locations still. IOW need to pass ocaml values here by-reference (where the reference itself is registered with gc somehow), not by-value.

-- 

  reply	other threads:[~2020-12-21 22:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-20 19:56 christophe
2020-12-20 22:22 ` christophe
2020-12-21 18:37 ` Xavier Leroy
2020-12-21 20:40   ` Christophe Raffalli
2020-12-21 21:03     ` Christophe Raffalli
2020-12-21 22:32       ` ygrek [this message]
2020-12-21 23:11         ` Christophe Raffalli

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=20201221153213.1844759e@autistici.org \
    --to=ygrek@autistici.org \
    --cc=Xavier.Leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=christophe@raffalli.eu \
    /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).