caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Török Edwin" <edwin+ml-ocaml@etorok.net>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Segfault in C++ stub with many 'new' allocations
Date: Sat, 17 Nov 2012 21:10:48 +0200	[thread overview]
Message-ID: <50A7E138.9090601@etorok.net> (raw)
In-Reply-To: <0BEF3A04-3297-4084-BE4D-13ACCC4D431E@inria.fr>

On 11/17/2012 08:42 PM, Samuel Hornus wrote:
> 
> On 17 nov. 2012, at 19:35, Kakadu wrote:
> 
>> 2) AFAIR there are functions like register_global_root which prevents GC from moving values.
> 
> Thank you Kakadu. It is interesting to know that one can use this function directly. I knew its existence only through the CAML[x]param* macros…
> 
> Regarding my first question, if it can help, here is the relevant part of my C++ code:
> extern "C" value ann_create_bd_tree_flat_ba (value ba, value n, value dim)
> {
>     CAMLparam3(ba,n,dim);
>     ANNbd_tree * ptr = create_bd_tree_flat((ANNcoord*)Caml_ba_data_val(ba), Int_val(n), Int_val(dim));
>     CAMLreturn ((value)ptr);

I don't think this is safe. Shouldn't the return value be wrapped in a custom block?
If the GC tries to interpret this as an OCaml value (which it isn't) it might crash.

--Edwin

  reply	other threads:[~2012-11-17 19:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-17 18:29 Samuel Hornus
2012-11-17 18:35 ` Kakadu
2012-11-17 18:42   ` Samuel Hornus
2012-11-17 19:10     ` Török Edwin [this message]
2012-11-17 19:18       ` Samuel Hornus
2012-11-17 19:50       ` Markus Mottl
2012-11-17 19:46 ` Markus Mottl
2012-11-17 22:45   ` Samuel Hornus

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=50A7E138.9090601@etorok.net \
    --to=edwin+ml-ocaml@etorok.net \
    --cc=caml-list@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;
as well as URLs for NNTP newsgroup(s).