From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marius Vollmer Newsgroups: gmane.lisp.guile.devel Subject: Re: module GC bug Date: Thu, 14 Jul 2005 00:02:29 +0300 Message-ID: <87irzeh122.fsf@zagadka.de> References: <42A8D188.20007@xs4all.nl> <87fyuq1mrr.fsf@zagadka.de> <42CEF39F.2040608@xs4all.nl> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1121288868 18553 80.91.229.2 (13 Jul 2005 21:07:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 13 Jul 2005 21:07:48 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Jul 13 23:07:47 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DsoRe-0002Ms-Ou for guile-devel@m.gmane.org; Wed, 13 Jul 2005 23:07:07 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DsoTL-00087X-TG for guile-devel@m.gmane.org; Wed, 13 Jul 2005 17:08:51 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DsoRM-0006mS-GW for guile-devel@gnu.org; Wed, 13 Jul 2005 17:06:49 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DsoRH-0006iV-BG for guile-devel@gnu.org; Wed, 13 Jul 2005 17:06:43 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DsoRD-0006hX-Fg for guile-devel@gnu.org; Wed, 13 Jul 2005 17:06:39 -0400 Original-Received: from [213.243.153.37] (helo=smtp1.pp.htv.fi) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DsoV8-0003Ts-Bb for guile-devel@gnu.org; Wed, 13 Jul 2005 17:10:42 -0400 Original-Received: from zagadka.ping.de (cs181072157.pp.htv.fi [82.181.72.157]) by smtp1.pp.htv.fi (Postfix) with SMTP id A00807FCAA for ; Thu, 14 Jul 2005 00:02:29 +0300 (EEST) Original-Received: (qmail 4787 invoked by uid 1000); 13 Jul 2005 21:02:29 -0000 Original-To: Han-Wen Nienhuys In-Reply-To: <42CEF39F.2040608@xs4all.nl> (Han-Wen Nienhuys's message of "Fri, 08 Jul 2005 23:43:59 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:5162 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:5162 Han-Wen Nienhuys writes: >> I think the right fix is to change the weak hashtable marking >> algorithm to properly cope with circular references like this. I will >> try this and then come back to you. > > Interesting. How would you go about doing that? The marking would would rougly look like this (some special cases are not considered, like improper alists): mark OBJ: if mark of OBJ is set: return set mark of OBJ if OBJ is a weak vector put it on POSTPONED_OBJECTS else mark references of OBJ gc: POSTPONED_OBJECTS = '() mark all root references while POSTPONED_OBJECTS not empty OBJS = POSTPONED_OBJECTS POSTPONED_OBJECTS = '() mark_weak_vector all OBJS sweep mark_weak_vector OBJ: for all elements ELT of OBJ: for all pairs P on list ELT: if P is marked, break ITEM = car of P if ITEM is a pair: if (OBJ has weak keys and car of ITEM is unmarked) or (OBJ has weak values and cdr of ITEM is unmarked) remove P from ELT else: mark ITEM (recursively) set mark of P The non-trivial stuff is to integrate this properly with the abstract hashtables (but I have basically done this already as well). -- GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405 _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel