guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[VM] Should `compile' always be visible?


From: Ludovic Courtès
Subject: [VM] Should `compile' always be visible?
Date: Fri, 20 Feb 2009 01:45:37 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.90 (gnu/linux)

Hello,

Consider the following problem:

  $ echo '(define-module (foo) :export (compile))' > t.scm
  $ guile t.scm
  guile: uncaught throw to misc-error: ("mutex already locked by thread")

The Scheme backtrace when `scm_ithrow ()' gets called looks like this:

   213:  0* [#<program 809dea0 ()>]
  In unknown file:
     ?:  1* [primitive-load "t.scm"]
  In t.scm:
     1:  2* (begin (let* ((m #)) (set-current-module m) m))
  In unknown file:
     ?:  3  (let* ((m (process-define-module #))) (set-current-module m) m)
     ?:  4* [process-define-module ((foo) #:export (compile))]
  In (boot-9.scm):
  1994:  5* [process-define-module ((foo) #:export (compile))]
  1301:  6  [call-with-deferred-observers #]
  In unknown file:
     ?:  7* [dynamic-wind # # #]
  In #:
  2005:  8* [#<program 809dc30 at (boot-9.scm):2002:11 ()>]
  In (boot-9.scm):
  2916:  9  [module-export! #<directory (foo) 809dd30> (compile)]
  In unknown file:
     ?: 10* [for-each #<program 8066760 at (boot-9.scm):2915:14 (name)> 
(compile)]
  In (boot-9.scm):
  2917: 11* [#<program 8066760 at (boot-9.scm):2915:14 (name)> compile]
  1518: 12  [module-ensure-local-variable! #<directory (foo) 809dd30> compile]
  In unknown file:
     ?: 13* [module-local-variable #<directory (foo) 809dd30> compile]
  In (boot-9.scm):
  2103: 14* [b #<autoload (system base compile) 8087720> compile #f]
  1847: 15  [# #]
  In #: 
  1879: 16  [try-load-module (system base compile)]

  [...]

  In unknown file:
     ?: 23* [load-compiled/vm 
"/home/ludo/soft/share/guile/1.9/system/base/compile.go"]

  [...]

  In unknown file:
     ?: 36* [load-compiled/vm 
"/home/ludo/soft/share/guile/1.9/system/base/syntax.go"]
  In (syntax.scm):
    22: 37* [#<program 809bc30 ()>]
  In (boot-9.scm):
  1994: 38  [process-define-module (# # # # ...)]
  1301: 39  [call-with-deferred-observers #]

The problem is that `call-with-deferred-observers' is called
reentrantly, hence the double lock.

This is caused by this autoload in `boot-9.scm':

  (module-autoload! the-scm-module
                    '(system base compile)
                    '(compile
                      compile-time-environment))

Do we really need it?  Guile `master' doesn't put any autoload in the
global namespace, only in `guile-user-module', thus only affecting the
REPL.

Anyway, I'll commit the following fix, which can't hurt.

Thanks,
Ludo'.

diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 0cf83e6..5422385 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/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,2009
 ;;;; Free Software Foundation, Inc.
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
@@ -1286,7 +1286,7 @@
   *unspecified*)
 
 (define module-defer-observers #f)
-(define module-defer-observers-mutex (make-mutex))
+(define module-defer-observers-mutex (make-mutex 'recursive))
 (define module-defer-observers-table (make-hash-table))
 
 (define (module-modified m)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]