caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: John Carr <jfc@mit.edu>
To: Adrien <camaradetux@gmail.com>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Understanding usage by the runtime
Date: Wed, 04 Jan 2012 14:37:50 -0500	[thread overview]
Message-ID: <201201041937.q04JbpSf028441@outgoing.mit.edu> (raw)
In-Reply-To: <CAP5QFJk1GSDSizVwyQw+-aX_eWC71vPEBpXUepY4Vv9iYO6=Jw@mail.gmail.com>




> There is however something to do. Quoting lablgtk's README:
> > IMPORTANT: Some Gtk data structures are allocated in the Caml heap,
> > and their use in signals (Gtk functions internally cally callbacks)
> > relies on their address being stable during a function call. For
> > this reason automatic compation is disabled in GtkMain. If you need
> > it, you may use compaction through Gc.compact where it is safe
> > (timeouts, other threads...), but do not enable automatic compaction.
> 
> I've never really understood why it worked: I'm surprised the GC would
> update addresses stored in the C side of GTK.

I think the problem is, a C function can invoke a callback that calls
ocaml code that moves the object being operated on by the C function.
Because the C function is precompiled it does not register its copy of
the pointer as a GC root.  When the callback returns the C function's
pointer is invalid.

This should be fixable with another level of indirection.  Finalization
can free the C object.  I infer from reading the source that the extra
level of indirection is considered an unacceptable penalty.


  reply	other threads:[~2012-01-04 19:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-30 23:45 orbitz
2011-12-31  9:11 ` David Baelde
2011-12-31 15:33   ` orbitz
2012-01-01 12:44     ` Richard W.M. Jones
2012-01-04 18:03       ` Damien Doligez
2012-01-04 18:48         ` Adrien
2012-01-04 19:37           ` John Carr [this message]
2012-01-07  5:43       ` orbitz
2012-01-08 18:45         ` Richard W.M. Jones
2012-01-08 19:00           ` Richard W.M. Jones
2012-01-08 22:33             ` Török Edwin
2012-01-09 14:31               ` Richard W.M. Jones
2012-01-09 21:07                 ` Richard W.M. Jones
2012-01-08 22:50           ` orbitz
2012-01-08 23:02             ` Richard W.M. Jones
2012-01-08 23:26               ` orbitz

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=201201041937.q04JbpSf028441@outgoing.mit.edu \
    --to=jfc@mit.edu \
    --cc=camaradetux@gmail.com \
    --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).