From 490cf75094167556289716c49ad43ad827f1d0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 5 Nov 2008 18:50:23 +0100 Subject: [PATCH] Work around unintentional retention of modules by the GC. This reverts par of "Document the failure of `gc.test' wrt. unused modules." (commit 328efeb9a66dddcf78a24fad96d3db58e9c3375d.) * ice-9/boot-9.scm (set-module-eval-closure!): Don't set the `module' property on CLOSURE. * libguile/modules.c (scm_lookup_closure_module): Call `abort ()' to make it clear that code that uses the `module' property no longer works. That code is unused anyway. --- ice-9/boot-9.scm | 16 ++++++++++++---- libguile/modules.c | 8 +++++++- test-suite/tests/gc.test | 3 --- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/ice-9/boot-9.scm b/ice-9/boot-9.scm index 5a74f945f..1a0283da1 100644 --- a/ice-9/boot-9.scm +++ b/ice-9/boot-9.scm @@ -1,6 +1,6 @@ ;;; installed-scm-file -;;;; Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007 +;;;; Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008 ;;;; Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or @@ -1223,8 +1223,6 @@ ;; 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)))) @@ -1264,7 +1262,17 @@ ;; Make it possible to lookup the module from the environment. ;; This implementation is correct since an eval closure can belong ;; to maximally one module. - (set-procedure-property! closure 'module module)))) + + ;; XXX: The following line introduces a circular reference that + ;; precludes garbage collection of modules with the current weak hash + ;; table semantics (see + ;; http://thread.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/2465 + ;; for details). Since it doesn't appear to be used (only in + ;; `scm_lookup_closure_module ()', which has 1 caller), we just comment + ;; it out. + + ;(set-procedure-property! closure 'module module) + ))) diff --git a/libguile/modules.c b/libguile/modules.c index d59428c8d..04527a529 100644 --- a/libguile/modules.c +++ b/libguile/modules.c @@ -255,7 +255,13 @@ scm_lookup_closure_module (SCM proc) return SCM_PACK (SCM_SMOB_DATA (proc)); else { - SCM mod = scm_procedure_property (proc, sym_module); + SCM mod; + + /* FIXME: The `module' property is no longer set. See + `set-module-eval-closure!' in `boot-9.scm'. */ + abort (); + + mod = scm_procedure_property (proc, sym_module); if (scm_is_false (mod)) mod = the_root_module (); return mod; diff --git a/test-suite/tests/gc.test b/test-suite/tests/gc.test index 0fdfaaf6d..407c4a286 100644 --- a/test-suite/tests/gc.test +++ b/test-suite/tests/gc.test @@ -59,9 +59,6 @@ (with-test-prefix "gc" (pass-if "Unused modules are removed" - ;; 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))