unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Chris Vine <chris@cvine.freeserve.co.uk>
To: guile-user@gnu.org
Subject: Re: Need for scm_remember_upto_here_* in guile-2.0
Date: Wed, 23 Sep 2015 09:41:46 +0100	[thread overview]
Message-ID: <20150923094146.3f66b926@laptop.homenet> (raw)
In-Reply-To: <87r3lpa95o.fsf@fencepost.gnu.org>

On Wed, 23 Sep 2015 09:26:27 +0200
David Kastrup <dak@gnu.org> wrote:
> Chris Vine <chris@cvine.freeserve.co.uk> writes:
> 
> > On Wed, 23 Sep 2015 00:35:09 +0100
> > Chris Vine <chris@cvine.freeserve.co.uk> wrote:
> >> I think you were trying to answer my question, which was: "... is
> >> the point that the scm_remember_upto_here_* functions are in
> >> practice only needed for smobs which provide their own free
> >> function?" (that is, which have no finalisers). I think you were
> >> giving the answer "Yes".
> >
> > Err, "... which have finalisers".
> >
> > Assuming this is the case, the guile manual example is rather
> > unhelpful.
> 
> There are other forms of finalization than giving back memory, like
> closing file descriptors, relinquishing a lock or semaphore and so on.
> Also, a pointer to an array (rather than something more opaque like
> SCM) is much more likely to be subject to strength reduction and
> address arithmetic by the compiler, leading to a situation where
> looping through some array does not leave a live pointer in
> registers and stack frame in a form recognizable by libgc.

I am not sure if we are on the same page.  I realise that finalisers are
not only concerned with memory.  In fact, because there is proper
garbage collection in guile-2.0, in a well designed smob memory is
likely to be the least common thing they manage.  It so happens that
you set the smob's finalisers (whatever they happen to do) with
scm_set_smob_free() (the "free function" that I referred to).

However, I haven't understood your point about arrays.  If they are
allocated with malloc() you need a finaliser and you may need to call
scm_remember_upto_here_1() to prevent the smob's finaliser from firing
while they are still in use.  If they are allocated with scm_gc_malloc()
you don't, as I understand it.  Were you making a point in addition to
that, and if so could you expand on it for me?

Chris



  reply	other threads:[~2015-09-23  8:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-12 12:27 Need for scm_remember_upto_here_* in guile-2.0 Chris Vine
2015-09-22 14:54 ` Ludovic Courtès
2015-09-22 15:26   ` David Kastrup
2015-09-22 16:24     ` Mark H Weaver
2015-09-22 17:08       ` David Kastrup
2015-09-22 21:13       ` Ludovic Courtès
2015-09-22 23:35         ` Chris Vine
2015-09-22 23:48           ` Chris Vine
2015-09-23  7:26             ` David Kastrup
2015-09-23  8:41               ` Chris Vine [this message]
2015-09-23  8:54                 ` David Kastrup
2015-09-23  9:40                   ` Chris Vine
2015-09-23 12:27                     ` David Kastrup
2015-09-23 16:45                       ` Chris Vine

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=20150923094146.3f66b926@laptop.homenet \
    --to=chris@cvine.freeserve.co.uk \
    --cc=guile-user@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).