guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need for scm_remember_upto_here_* in guile-2.0


From: Chris Vine
Subject: Re: Need for scm_remember_upto_here_* in guile-2.0
Date: Wed, 23 Sep 2015 00:35:09 +0100

On Tue, 22 Sep 2015 23:13:45 +0200
address@hidden (Ludovic Courtès) wrote:

> Mark H Weaver <address@hidden> skribis:
> 
> > David Kastrup <address@hidden> writes:
> >
> >> address@hidden (Ludovic Courtès) writes:
> >>
> >>> In practice scm_remember_upto_here_* is useless with libgc, since
> >>> libgc also tracks pointers in registers.
> >>
> >> Sounds like a big non-sequitur.  scm_remember_upto_here_* is for
> >> keeping SCM values active (including in registers).  Any
> >> conversion of an SCM value to some other data depending on it will
> >> not protect the SCM value as such and may lead to
> >> collection/finalization of the SCM cell (calling guardians,
> >> removing from weak hashtables and so on).
> >
> > I think David is right.  Consider the following case: a SMOB
> > contains a pointer to a block allocated by 'malloc' and freed by
> > the SMOB freeing procedure.  Some C code starts with a SCM value
> > for that SMOB, uses it to obtain a pointer to the malloc'd block,
> > and then discards the SCM value and proceeds to do a long-running
> > job on the malloc'd block.  If there are no other references to the
> > SCM value, Boehm GC can free the SMOB and call its finalizer, which
> > frees the malloc'd block.  The long-running job in C continues to
> > access the freed block.
> 
> Indeed, that’s a valid scenario.
> 
> My “in practice” assumed no finalizers and only GC-managed memory,
> I guess.

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".

Chris



reply via email to

[Prev in Thread] Current Thread [Next in Thread]