From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Newsgroups: gmane.lisp.guile.bugs Subject: bug#28590: [PATCH 3/7] weak-table: Make sure 'move_disappearing_links' actually moves links. Date: Tue, 3 Oct 2017 13:43:48 +0200 Message-ID: <20171003114352.13984-4-ludo@gnu.org> References: <20171003114352.13984-1-ludo@gnu.org> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1507031208 20124 195.159.176.226 (3 Oct 2017 11:46:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 3 Oct 2017 11:46:48 +0000 (UTC) Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , 28590@debbugs.gnu.org To: wingo@igalia.com Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Tue Oct 03 13:46:31 2017 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dzLeb-0003kP-N2 for guile-bugs@m.gmane.org; Tue, 03 Oct 2017 13:46:25 +0200 Original-Received: from localhost ([::1]:57959 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzLej-0003DL-76 for guile-bugs@m.gmane.org; Tue, 03 Oct 2017 07:46:33 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzLeI-00030T-Rk for bug-guile@gnu.org; Tue, 03 Oct 2017 07:46:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzLeH-0006dO-Qo for bug-guile@gnu.org; Tue, 03 Oct 2017 07:46:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:36646) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dzLeH-0006dK-Nf for bug-guile@gnu.org; Tue, 03 Oct 2017 07:46:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dzLeH-0006lq-Ho; Tue, 03 Oct 2017 07:46:05 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 03 Oct 2017 11:46:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28590 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 28590-submit@debbugs.gnu.org id=B28590.150703111625892 (code B ref 28590); Tue, 03 Oct 2017 11:46:05 +0000 Original-Received: (at 28590) by debbugs.gnu.org; 3 Oct 2017 11:45:16 +0000 Original-Received: from localhost ([127.0.0.1]:45320 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dzLdT-0006jT-RJ for submit@debbugs.gnu.org; Tue, 03 Oct 2017 07:45:16 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42622) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dzLdQ-0006hp-Jo for 28590@debbugs.gnu.org; Tue, 03 Oct 2017 07:45:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzLdF-0005s3-Dj for 28590@debbugs.gnu.org; Tue, 03 Oct 2017 07:45:04 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:59153) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzLcW-0005BN-Mg; Tue, 03 Oct 2017 07:44:16 -0400 Original-Received: from [193.50.110.164] (port=33316 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dzLcW-0000d1-7s; Tue, 03 Oct 2017 07:44:16 -0400 X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171003114352.13984-1-ludo@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:8846 Archived-At: * libguile/weak-table.c (move_disappearing_links): Check the return value of 'GC_move_disappearing_link' and call 'register_disappearing_links' upon GC_NOT_FOUND. (GC_move_disappearing_link) [!HAVE_GC_MOVE_DISAPPEARING_LINK]: Adjust to return the error code. --- libguile/weak-table.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/libguile/weak-table.c b/libguile/weak-table.c index 1aa2a0fcc..7d8633165 100644 --- a/libguile/weak-table.c +++ b/libguile/weak-table.c @@ -153,11 +153,16 @@ unregister_disappearing_links (scm_t_weak_entry *entry, } #ifndef HAVE_GC_MOVE_DISAPPEARING_LINK -static void +static int GC_move_disappearing_link (void **from, void **to) { - GC_unregister_disappearing_link (from); - SCM_I_REGISTER_DISAPPEARING_LINK (to, *to); + int err; + + err = GC_unregister_disappearing_link (from); + if (err == GC_SUCCESS) + err = SCM_I_REGISTER_DISAPPEARING_LINK (to, *to); + + return err; } #endif @@ -165,13 +170,33 @@ static void move_disappearing_links (scm_t_weak_entry *from, scm_t_weak_entry *to, SCM key, SCM value, scm_t_weak_table_kind kind) { + int err; + if ((kind == SCM_WEAK_TABLE_KIND_KEY || kind == SCM_WEAK_TABLE_KIND_BOTH) && SCM_HEAP_OBJECT_P (key)) - GC_move_disappearing_link ((void **) &from->key, (void **) &to->key); + { + err = GC_move_disappearing_link ((void **) &from->key, + (void **) &to->key); + if (err == GC_NOT_FOUND) + /* Link disappeared. */ + register_disappearing_links (to, key, value, + SCM_WEAK_TABLE_KIND_KEY); + else + assert (err == GC_SUCCESS); + } if ((kind == SCM_WEAK_TABLE_KIND_VALUE || kind == SCM_WEAK_TABLE_KIND_BOTH) && SCM_HEAP_OBJECT_P (value)) - GC_move_disappearing_link ((void **) &from->value, (void **) &to->value); + { + err = GC_move_disappearing_link ((void **) &from->value, + (void **) &to->value); + if (err == GC_NOT_FOUND) + /* Link disappeared. */ + register_disappearing_links (to, key, value, + SCM_WEAK_TABLE_KIND_VALUE); + else + assert (err == GC_SUCCESS); + } } static void -- 2.14.2