From 637dc2464591541d6bf72c8a2464b8f03f90f4fc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Wed, 13 Nov 2019 15:57:22 +0100
Subject: [PATCH] Pike.count_memory: Empty mc_complete before reuse.

Fixes assertion failures for mc_complete when running the
testsuite with -d.

Likely to improve the ordo for count_memory() by avoiding to
handle the same items multiple times.

Fixes [PIKE-226].
---
 .gitattributes | 1 -
 src/gc.c       | 7 ++++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/.gitattributes b/.gitattributes
index 5fe7a63fa3..e4b2c64a7e 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -378,7 +378,6 @@ testfont binary
 /src/fsort.c foreign_ident
 /src/fsort.h foreign_ident
 /src/fsort_template.h foreign_ident
-/src/gc.c foreign_ident
 /src/gc.h foreign_ident
 /src/global.h foreign_ident
 /src/hashtable.c foreign_ident
diff --git a/src/gc.c b/src/gc.c
index 1ae9fe970f..53a01586bd 100644
--- a/src/gc.c
+++ b/src/gc.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: gc.c,v 1.330 2008/10/12 21:49:56 mast Exp $
+|| $Id$
 */
 
 #include "global.h"
@@ -5511,6 +5511,11 @@ void f_count_memory (INT32 args)
       } while (m != &mc_complete);
     }
 
+    /* We've moved all the markers on mc_complete to the work queue,
+     * so we need to empty mc_complete in order to use it again for
+     * the next batch of indirect markers.
+     */
+    DL_MAKE_EMPTY(mc_complete);
     DL_MOVE (mc_indirect, mc_complete);
 
     TOGGLE_EXT_FLAGS();
-- 
GitLab