From: Christophe Raffalli <christophe@raffalli.eu>
To: ygrek <ygrek@autistici.org>
Cc: Xavier Leroy <Xavier.Leroy@inria.fr>, caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Global roots
Date: Tue, 22 Dec 2020 00:11:39 +0100 [thread overview]
Message-ID: <X+Erq7mY7etyzucJ@oulala> (raw)
In-Reply-To: <20201221153213.1844759e@autistici.org>
[-- Attachment #1: Type: text/plain, Size: 1166 bytes --]
Le 20-12-21 15:32:13, ygrek a écrit :
> 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.
>
> --
Many thanks, this is clearly my problem and sounds completely logical! I should have see this myself!
Many the documentation should say this and show an example of callback acquiring the runtime system ? I update my issue in github.
Thanks again,
Christophe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2020-12-21 23:11 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
2020-12-21 23:11 ` Christophe Raffalli [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=X+Erq7mY7etyzucJ@oulala \
--to=christophe@raffalli.eu \
--cc=Xavier.Leroy@inria.fr \
--cc=caml-list@inria.fr \
--cc=ygrek@autistici.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