caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Goswin von Brederlow <goswin-v-b@web.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Why is struct caml_ba_proxy allocated outside the GC heap and why doesn't it have a finalizer?
Date: Tue, 4 Feb 2014 16:32:21 +0100	[thread overview]
Message-ID: <20140204153221.GA20077@frosties> (raw)
In-Reply-To: <CAP_800qpOzaTYSvz806tfsXxxCx0fs0dNAzoe51NykpoChd+Eg@mail.gmail.com>

On Sat, Feb 01, 2014 at 09:06:54PM -0500, Markus Mottl wrote:
> On Sat, Feb 1, 2014 at 8:38 PM, Goswin von Brederlow <goswin-v-b@web.de> wrote:
> > The GC knows which pointers point inside the GC heap and which point
> > outside. So there is no problem there. The pointer must just not exist
> > after the destination has been freed or it might accidentaly point to
> > inside the next GC heap. Can't happen in this use case.
> 
> Exactly.  Though the GC checks whether a pointer actually points into
> the OCaml heap before following it, it does require some care to
> guarantee that the pointer, if still reachable by the GC, is
> invalidated (e.g. set to NULL) before associated memory is freed.
> This may indeed not be that hard to achieve for the bigarray module.
> I still prefer 2), which would also be easier to add to the current
> implementation without breaking existing code.
> 
> Regards,
> Markus
> 
> -- 
> Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com

Time to try out that new ocaml program to use git-hub for patches to
the compiler. I will go with option 2 because it will not change
anything in the compiler and the optimizations for bigarrays itself.
It will only affect the C code fo allocation and dinalization. So
should be far easier.

I think I will add a new flag to the Bigarray structure that says when
a "free" function was added to the proxy object. That way even if some
software creates the proxy object themself (and won't have the free_fn
pointer) this will work.

MfG
	Goswin

      reply	other threads:[~2014-02-04 15:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-01 16:42 Goswin von Brederlow
2014-02-01 20:49 ` Markus Mottl
2014-02-02  1:38   ` Goswin von Brederlow
2014-02-02  2:06     ` Markus Mottl
2014-02-04 15:32       ` Goswin von Brederlow [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=20140204153221.GA20077@frosties \
    --to=goswin-v-b@web.de \
    --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).