unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: wingo@igalia.com
Cc: "Ludovic Courtès" <ludo@gnu.org>, 28590@debbugs.gnu.org
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	[thread overview]
Message-ID: <20171003114352.13984-4-ludo@gnu.org> (raw)
In-Reply-To: <20171003114352.13984-1-ludo@gnu.org>

* 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






  parent reply	other threads:[~2017-10-03 11:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-25  8:49 bug#28590: Weak tables in 2.2.2 grow indefinitely Ludovic Courtès
2017-09-26  9:57 ` Ludovic Courtès
2017-10-02  9:53 ` Ludovic Courtès
2017-10-03 11:43 ` bug#28590: [PATCH 0/7] Attempt to reduce memory growth Ludovic Courtès
2017-10-03 11:43   ` bug#28590: [PATCH 1/7] weak-table: Fix unbounded growth of the disappearing link table Ludovic Courtès
2017-10-03 11:43   ` bug#28590: [PATCH 2/7] weak-table: Stress the GC a little less when resizing Ludovic Courtès
2017-10-03 11:43   ` Ludovic Courtès [this message]
2017-10-03 11:43   ` bug#28590: [PATCH 4/7] weak-table: Always unregister previous links when inserting an entry Ludovic Courtès
2017-10-03 11:43   ` bug#28590: [PATCH 5/7] weak-table: 'move_weak_entry' reports disappeared links Ludovic Courtès
2017-10-03 11:43   ` bug#28590: [PATCH 6/7] weak-table: 'rob_from_rich' accounts for disappeared entries Ludovic Courtès
2017-10-03 11:43   ` bug#28590: [PATCH 7/7] weak-table: Resize less frequently Ludovic Courtès
2017-10-04 13:09   ` bug#28590: [PATCH 0/7] Attempt to reduce memory growth Ludovic Courtès
2017-10-05 14:09     ` Ludovic Courtès
2017-11-07 10:58 ` bug#28590: Weak tables in 2.2.2 grow indefinitely 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=20171003114352.13984-4-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=28590@debbugs.gnu.org \
    --cc=wingo@igalia.com \
    /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).