unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: guile-devel <guile-devel@gnu.org>
Subject: Unordered finalization, SMOBs, finalizers, and mark functions
Date: Mon, 26 Jan 2015 10:52:02 +0100	[thread overview]
Message-ID: <87r3uhg98d.fsf@pobox.com> (raw)

Hi,

Guile currently uses the Boehm-Demers-Weiser collector with "Java-style
finalization", which is to say that finalizers are unordered.  This is
good in the sense that Guile's GC can collect cycles of objects with
finalizers that point to each other.  It also has some understudied
disadvantages or strange behavior.

One disadvantage is that with the default topological finalization
order of BDW-GC, cycles of objects with finalizers are uncollectable.  I
think that BDW-GC will warn to the console when this is the case, in the
default mode, so perhaps it's not that bad.

Another disadvantage is that running the finalizer of object O1 which
links to finalizable object O2 could see O2 after O2's finalizer has
been run, because finalizers are unordered.  This is almost certainly
not what you would expect.

Also, if O1 has a mark function, you could mark O1 when O1 is on the
finalization queue but not yet finalized, and O2 has already been
finalized -- so your mark functions also need to be ready to deal with
unordered finalization.

Keep in mind that in Guile 2.x, finalizers are uncommon.  They are
probably more common in user code than in Guile code, in the form of
SMOB free functions.  This is especially the case in code ported from
earlier Guile versions.

Useful links:

  Finalization
  http://hboehm.info/gc/finalization.html

  Finalizers, Threads, and the Java Memory Model
  http://hboehm.info/misc_slides/java_finalizers.pdf

  Foreign Object Memory Management
  http://www.gnu.org/software/guile/docs/master/guile.html/Foreign-Object-Memory-Management.html#Foreign-Object-Memory-Management

Open question: should Guile configure the BDW GC in a different way?
Topological finalization is desirable for all the reasons Boehm links in
that first article.  Should it allow the user to configure it?  I
believe it is currently unordered due to issues with guardians, but I
don't recall correctly.

Thoughts?

Andy
-- 
http://wingolog.org/



             reply	other threads:[~2015-01-26  9:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-26  9:52 Andy Wingo [this message]
2015-03-04 10:10 ` Unordered finalization, SMOBs, finalizers, and mark functions Ludovic Courtès
2015-03-09 21:05   ` Andy Wingo
2015-03-10  7:59     ` Ludovic Courtès

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=87r3uhg98d.fsf@pobox.com \
    --to=wingo@pobox.com \
    --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).