From: Jeremy Yallop <yallop@gmail.com>
To: "Christoph Höger" <christoph.hoeger@tu-berlin.de>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Garbage collector woes
Date: Mon, 4 Jul 2016 17:21:04 +0100 [thread overview]
Message-ID: <CAAxsn=HE-DsnuFDvsm7cK+m3d8i96kYG=Dhe6rohvn5DUFt+Fg@mail.gmail.com> (raw)
In-Reply-To: <03f0318e-3268-da14-d6e9-6efdcfcab567@tu-berlin.de>
On 4 July 2016 at 17:04, Christoph Höger <christoph.hoeger@tu-berlin.de> wrote:
> I have a program using OCaml callbacks, one of these callbacks looks is
> the following:
>
> /* Callbacks */
> CAMLprim iconv(void* user_data, double t, double const *x, double *cond) {
> CAMLparam0();
> CAMLlocal3(ml_t, ml_x, ml_cond);
> const value desc = *((value*)user_data);
I'm guessing that 'desc' points to a block and N, MFIT and ICONV are
field accessors.
If so, you need to register 'desc' as a root here, since
caml_copy_double or caml_ba_alloc_dims could trigger a gc, moving desc
before it's next used.
It's probably also better not to call your exported function 'iconv',
since there's a POSIX function of that name.
> /* Wrap the values in fresh big arrays */
> ml_t = caml_copy_double(t);
> ml_x = caml_ba_alloc_dims(CAML_BA_FLOAT64 | CAML_BA_C_LAYOUT, 1,
> (double*)x, Int_val(N(desc)));
> ml_cond = caml_ba_alloc_dims(CAML_BA_FLOAT64 | CAML_BA_C_LAYOUT, 1,
> cond, Int_val(MFIT(desc)));
>
> /* call the OCaml callback */
> caml_callback3(ICONV(desc), ml_t, ml_x, ml_cond);
> CAMLreturn0;
> }
next prev parent reply other threads:[~2016-07-04 16:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-04 16:04 Christoph Höger
2016-07-04 16:21 ` Jeremy Yallop [this message]
2016-07-04 17:06 ` Christoph Höger
2016-07-04 17:44 ` Jeremy Yallop
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='CAAxsn=HE-DsnuFDvsm7cK+m3d8i96kYG=Dhe6rohvn5DUFt+Fg@mail.gmail.com' \
--to=yallop@gmail.com \
--cc=caml-list@inria.fr \
--cc=christoph.hoeger@tu-berlin.de \
/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