From 328efeb9a66dddcf78a24fad96d3db58e9c3375d Mon Sep 17 00:00:00 2001 From: Ludovic Courtes Date: Sun, 21 Oct 2007 18:53:50 +0000 Subject: [PATCH] Document the failure of `gc.test' wrt. unused modules. * test-suite/tests/gc.test (Unused modules are removed): Use guardians instead of `gc-live-object-stats'. Explain failure (FIXME). * ice-9/boot-9.scm (make-module): Add `FIXME' about circular reference. git-archimport-id: lcourtes@laas.fr--2006-libre/guile-core--boehm-gc--0--patch-9 --- ice-9/boot-9.scm | 2 ++ test-suite/tests/gc.test | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ice-9/boot-9.scm b/ice-9/boot-9.scm index 6ada33c68..5a74f945f 100644 --- a/ice-9/boot-9.scm +++ b/ice-9/boot-9.scm @@ -1223,6 +1223,8 @@ ;; We can't pass this as an argument to module-constructor, ;; because we need it to close over a pointer to the module ;; itself. + ;; FIXME: This creates a circular reference between MODULE and its + ;; standard eval closure which precludes them from being collected. (set-module-eval-closure! module (standard-eval-closure module)) module)))) diff --git a/test-suite/tests/gc.test b/test-suite/tests/gc.test index abd714b9a..d881aba17 100644 --- a/test-suite/tests/gc.test +++ b/test-suite/tests/gc.test @@ -1,5 +1,5 @@ ;;;; gc.test --- test guile's garbage collection -*- scheme -*- -;;;; Copyright (C) 2000, 2001, 2004, 2006 Free Software Foundation, Inc. +;;;; Copyright (C) 2000, 2001, 2004, 2006, 2007 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -59,13 +59,17 @@ (with-test-prefix "gc" (pass-if "Unused modules are removed" - (let* - ((dummy (gc)) - (last-count (cdr (assoc - "eval-closure" (gc-live-object-stats))))) - - (for-each (lambda (x) (make-module)) (iota 1000)) + ;; FIXME: This test fails because of the circular reference + ;; created by `make-module' between the module itself and its + ;; standard eval closure. + (let* ((guard (make-guardian)) + (total 1000)) + + (for-each (lambda (x) (guard (make-module))) (iota total)) (gc) (gc) ;; twice: have to kill the weak vectors. - (= last-count (cdr (assoc "eval-closure" (gc-live-object-stats))))) - )) + (= (length (filter (lambda (x) + (eq? x #t)) + (map (lambda (x) (and (guard) #t)) + (iota total)))) + total))))