unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: ludo@gnu.org (Ludovic Courtès)
Cc: guile-devel@gnu.org
Subject: Re: ‘set-cdr!’ and weak-cdr pairs
Date: Sun, 01 May 2011 23:14:56 +0200	[thread overview]
Message-ID: <m37haaunqn.fsf@unquote.localdomain> (raw)
In-Reply-To: <87bp0wzo6l.fsf@gnu.org> ("Ludovic Courtès"'s message of "Sun, 27 Mar 2011 15:29:54 +0200")

Hi :)

On Sun 27 Mar 2011 15:29, ludo@gnu.org (Ludovic Courtès) writes:

> Andy Wingo <wingo@pobox.com> writes:
>
>> On Sun 13 Mar 2011 16:25, ludo@gnu.org (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.

Andy
-- 
http://wingolog.org/



  reply	other threads:[~2011-05-01 21:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-13 15:25 ‘set-cdr!’ and weak-cdr pairs Ludovic Courtès
2011-03-27 11:22 ` Andy Wingo
2011-03-27 13:29   ` Ludovic Courtès
2011-05-01 21:14     ` Andy Wingo [this message]
2011-05-05 18:20       ` 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=m37haaunqn.fsf@unquote.localdomain \
    --to=wingo@pobox.com \
    --cc=guile-devel@gnu.org \
    --cc=ludo@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).