From: Marius Vollmer <mvo@zagadka.de>
Cc: guile-devel@gnu.org
Subject: Re: scheme closures: crash during garbage collection
Date: Sat, 08 Jul 2006 18:06:37 +0300 [thread overview]
Message-ID: <87u05s2l1e.fsf@zagadka.de> (raw)
In-Reply-To: <87odwyt33x.fsf@ossau.uklinux.net> (Neil Jerram's message of "Mon, 12 Jun 2006 23:34:42 +0100")
Neil Jerram <neil@ossau.uklinux.net> writes:
>> Guile wants you to integrate your objects with its mark/sweep
>> approach, by providing appropriate smob marking functions, for
>> example.
>
> If I've understood correctly, this isn't possible in Gregory's
> scenario.
>
> (See
> http://lists.gnu.org/archive/html/guile-gtk-general/2006-06/msg00013.html
> if you didn't see the whole description on guile-gtk-general already.)
I think this (and also the problem of reference loops that easily form
over widgets and signal handlers) has been successfully solved in the
guile-gtk bindings of yore: http://www.gnu.org/software/guile-gtk/
Here is the comment describing the wrapping strategy for GObjects:
/* GtkObjects.
GtkObjects are wrapped with a smob. The smob of a GtkObject is
called its proxy. The proxy and its GtkObject are strongly
connected; that is, the GtkObject will stay around as long as the
proxy is referenced from Scheme, and the proxy will not be
collected as long as the GtkObject is used from outside of Scheme.
The lifetime of GtkObjects is controlled by a reference count,
while Scheme objects are managed by a tracing garbage collector
(mark/sweep). These two techniques are made to cooperate like
this: the pointer from the proxy to the GtkObject is reflected in
the reference count of the GtkObject. All proxies are kept in a
list and those that point to GtkObjects with a reference count
greater than the number of `internal' references are marked during
the marking phase of the tracing collector. An internal reference
is one that goes from a GtkObject with a proxy to another GtkObject
with a proxy. We can only find a subset of the true internal
references (because Gtk does not yet cooperate), but this should be
good enough.
By using this combination of tracing and reference counting it is
possible to break the cycle that is formed by the proxy pointing to
the GtkObject and the GtkObject pointing back. It is
straightforward to extend this to other kind of cycles that might
occur. For example, when connecting a Scheme procedure as a signal
handler, the procedure is very likely to have the GtkObject that it
is connected to in its environment. This cycle can be broken by
including the procedure in the set of Scheme objects that get
marked when we are tracing GtkObjects with a reference count
greater than the number of internal references.
Therefore, each proxy contains a list of `protects' that are marked
when the proxy itself is marked. In addition to this, there is
also a global list of `protects' that is used for Scheme objects
that are somewhere in Gtk land but not clearly associated with a
particular GtkObject (like timeout callbacks).
*/
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
next prev parent reply other threads:[~2006-07-08 15:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <64e2f6fe0606081528m4e5f9979yff9b8294ecedf6d2@mail.gmail.com>
2006-06-09 19:54 ` scheme closures: crash during garbage collection Neil Jerram
2006-06-09 21:54 ` Han-Wen Nienhuys
2006-06-10 9:40 ` Marius Vollmer
2006-06-12 22:34 ` Neil Jerram
2006-06-12 23:33 ` Han-Wen Nienhuys
2006-06-12 23:45 ` Neil Jerram
2006-07-08 15:06 ` Marius Vollmer [this message]
2006-07-12 21:48 ` Neil Jerram
2006-10-27 9:49 ` Andy Wingo
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
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87u05s2l1e.fsf@zagadka.de \
--to=mvo@zagadka.de \
--cc=guile-devel@gnu.org \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).