Mutex patch that fails to fix the bug.  This patch locks the entry and
exit of scm_sym2var().  However, it does not ammeliiorate the bug at all:
-- there are still deadlocks in garbage collection,
-- there are still crashes (with same stack trace as previously posted)
-- there are still races.

---
 libguile/modules.c |    8 ++++++++
 1 file changed, 8 insertions(+)

Index: guile-1.8.6/libguile/modules.c
===================================================================
--- guile-1.8.6.orig/libguile/modules.c	2008-12-23 11:45:23.000000000 -0600
+++ guile-1.8.6/libguile/modules.c	2008-12-23 12:09:31.000000000 -0600
@@ -451,6 +451,7 @@ SCM_DEFINE (scm_module_import_interface,
  */
 
 SCM scm_pre_modules_obarray;
+static scm_i_pthread_mutex_t scm_i_sym2var_mutex;
 
 SCM 
 scm_sym2var (SCM sym, SCM proc, SCM definep)
@@ -458,6 +459,7 @@ scm_sym2var (SCM sym, SCM proc, SCM defi
 {
   SCM var;
 
+  scm_pthread_mutex_lock(&scm_i_sym2var_mutex);
   if (SCM_NIMP (proc))
     {
       if (SCM_EVAL_CLOSURE_P (proc))
@@ -486,6 +488,7 @@ scm_sym2var (SCM sym, SCM proc, SCM defi
 	    }
 	}
     }
+  scm_i_pthread_mutex_unlock(&scm_i_sym2var_mutex);
 
   if (scm_is_true (var) && !SCM_VARIABLEP (var))
     SCM_MISC_ERROR ("~S is not bound to a variable", scm_list_1 (sym));
@@ -651,6 +654,11 @@ void
 scm_init_modules ()
 {
 #include "libguile/modules.x"
+  pthread_mutexattr_t symmutattr;
+  pthread_mutexattr_init (&symmutattr);
+  pthread_mutexattr_settype (&symmutattr, PTHREAD_MUTEX_RECURSIVE_NP);
+  scm_i_pthread_mutex_init (&scm_i_sym2var_mutex, &symmutattr);
+  pthread_mutexattr_destroy (&symmutattr);
   module_make_local_var_x_var = scm_c_define ("module-make-local-var!",
 					    SCM_UNDEFINED);
   scm_tc16_eval_closure = scm_make_smob_type ("eval-closure", 0);
