1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-16 08:40:19 +02:00

Work around unintentional retention of modules by the GC.

This reverts par of "Document the failure of `gc.test' wrt. unused modules."
(commit 328efeb9a6.)

* 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.
This commit is contained in:
Ludovic Courtès 2008-11-05 18:50:23 +01:00
parent 00b8057d1f
commit 490cf75094
3 changed files with 19 additions and 8 deletions

View file

@ -1,6 +1,6 @@
;;; installed-scm-file ;;; 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. ;;;; Free Software Foundation, Inc.
;;;; ;;;;
;;;; This library is free software; you can redistribute it and/or ;;;; 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, ;; We can't pass this as an argument to module-constructor,
;; because we need it to close over a pointer to the module ;; because we need it to close over a pointer to the module
;; itself. ;; 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)) (set-module-eval-closure! module (standard-eval-closure module))
module)))) module))))
@ -1264,7 +1262,17 @@
;; Make it possible to lookup the module from the environment. ;; Make it possible to lookup the module from the environment.
;; This implementation is correct since an eval closure can belong ;; This implementation is correct since an eval closure can belong
;; to maximally one module. ;; 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)
)))

View file

@ -255,7 +255,13 @@ scm_lookup_closure_module (SCM proc)
return SCM_PACK (SCM_SMOB_DATA (proc)); return SCM_PACK (SCM_SMOB_DATA (proc));
else 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)) if (scm_is_false (mod))
mod = the_root_module (); mod = the_root_module ();
return mod; return mod;

View file

@ -59,9 +59,6 @@
(with-test-prefix "gc" (with-test-prefix "gc"
(pass-if "Unused modules are removed" (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)) (let* ((guard (make-guardian))
(total 1000)) (total 1000))