caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Olivier Andrieu <andrieu@ijm.jussieu.fr>
To: ronniec95@lineone.net
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] GC with C issues
Date: Thu, 03 Feb 2005 13:50:11 +0100 (CET)	[thread overview]
Message-ID: <20050203.135011.30185183.andrieu@ijm.jussieu.fr> (raw)
In-Reply-To: <20050203113155.GA1860@cradle>

 ronniec95@lineone.net [Thu, 3 Feb 2005]:
 > On Thu, Feb 03, 2005 at 12:16:43PM +0100, Olivier Andrieu wrote:
 >  
 > >  > I can't see what I'm doing wrong in the allocation? I expect
 > >  > this to leak because I'm not freeing the allocated
 > >  > 'someObject' but I don't expect it to segfault though?
 > > 
 > > When you use CAMLparam in a function you have to exit it with
 > > CAMLreturn (or CAMLreturn0).
 > > 
 > > Do not use Store_field on your block: it's an Abstract block, not
 > > traced by the GC, use the Field macro directly :
 > > 
 > >  Field (retVal, 0) = (value) x;
 > 
 > Hmm... I thought I was only supposed to do that when using
 > alloc_small/alloc_shr interface? However using your method does
 > work in this small example though I'm worried about if something
 > unexpected will happen in more 'real-life' code...

No, Store_field should only be used on structured blocks (check the
manual). You can access and modify abstract blocks directly since
their content is not examined by the GC. 

Your code works fine in this small example because the block initially
contains zeroes, but an abstract block can contain anything and this can
confuse the GC if you use Store_field.

-- 
   Olivier


  reply	other threads:[~2005-02-03 12:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-03 10:58 ronniec95
2005-02-03 11:06 ` [Caml-list] " Daniel Bünzli
2005-02-03 11:25   ` ronniec95
2005-02-03 11:16 ` Olivier Andrieu
2005-02-03 11:31   ` ronniec95
2005-02-03 12:50     ` Olivier Andrieu [this message]
2005-02-03 12:52     ` Damien Doligez

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=20050203.135011.30185183.andrieu@ijm.jussieu.fr \
    --to=andrieu@ijm.jussieu.fr \
    --cc=caml-list@inria.fr \
    --cc=ronniec95@lineone.net \
    /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).