guile-devel
[Top][All Lists]
Advanced

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

Re: ‘set-cdr!’ and weak-cdr pairs


From: Ludovic Courtès
Subject: Re: ‘set-cdr!’ and weak-cdr pairs
Date: Thu, 05 May 2011 20:20:20 +0200
User-agent: Gnus/5.110017 (No Gnus v0.17) Emacs/24.0.50 (gnu/linux)

Hello!

Andy Wingo <address@hidden> writes:

> On Sun 27 Mar 2011 15:29, address@hidden (Ludovic Courtès) writes:
>
>> Andy Wingo <address@hidden> writes:
>>
>>> On Sun 13 Mar 2011 16:25, address@hidden (Ludovic Courtès) writes:
>>>
>>>> The problem is that ‘hash-create-handle!’ above created a weak-cdr
>>>> pair—i.e., a pair whose cdr is /not/ scanned for pointers—but ‘set-cdr!’
>>>> did not register a disappearing link from O to K+V.  Consequently, O
>>>> eventually gets collected, but K+V remains; the storage of O then gets
>>>> reused, and the cdr of K+V ends up containing either an unrelated or >an
>>>> invalid Scheme object.
>>>
>>> Given that we don't expose weak-pair constructors or accessors to
>>> Scheme, we should not expose weak pairs to Scheme.  What do you think
>>> about making it an error to hash-create-handle! on a weak table?  That
>>> way you never expose a weak pair to Scheme.  It does appear possible to
>>> discriminate in C between calls to create-handle! that occur due to ref
>>> / set! and those that are called explicitly.
>>
>> Yes, sounds good.  Would you like to work on it?  :-)
>
> I have done this now.  There were a few places within Guile that were
> using the get-handle / create-handle! API with weak hash tables, which I
> fixed.  It's quite possible that user code also does this, but between
> random failures to `(car x)' and preventative errors, I chose the
> latter.  We can back it down to a warning if that's the right thing to
> do, though.

Cool, thanks for working on it!  I skimmed over the relevant patches and
it looks good to me.

Ludo’.




reply via email to

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