[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #24867] `define' should be thread-safe
From: |
Linas Vepstas |
Subject: |
[bug #24867] `define' should be thread-safe |
Date: |
Tue, 23 Dec 2008 02:36:13 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.0.5) Gecko/2008121621 Ubuntu/8.04 (hardy) Firefox/3.0.5 |
Follow-up Comment #2, bug #24867 (project guile):
The following patch protects the update of the module hash tables
to be thread-safe. This is a partial solution to the bug reported
in https://savannah.gnu.org/bugs/?24867 This is not a full solution,
because other threads might still be reading the hash tables while
they are being updated, and thus may obtain stale/bad data.
Signed-off-by: Linas Vepstas <address@hidden>
---
libguile/modules.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
Index: guile-1.8.6/libguile/modules.c
===================================================================
--- guile-1.8.6.orig/libguile/modules.c 2008-12-22 18:38:41.000000000 -0600
+++ guile-1.8.6/libguile/modules.c 2008-12-22 20:22:19.000000000 -0600
@@ -555,11 +555,16 @@ scm_c_define (const char *name, SCM valu
return scm_define (scm_from_locale_symbol (name), value);
}
+scm_i_pthread_mutex_t scm_i_define_mutex;
+
SCM
scm_define (SCM sym, SCM value)
{
- SCM var =
+ SCM var;
+ scm_pthread_mutex_lock(&scm_i_define_mutex);
+ var =
scm_sym2var (sym, scm_current_module_lookup_closure (), SCM_BOOL_T);
+ scm_i_pthread_mutex_unlock(&scm_i_define_mutex);
SCM_VARIABLE_SET (var, value);
return var;
}
@@ -651,6 +656,8 @@ void
scm_init_modules ()
{
#include "libguile/modules.x"
+ scm_i_pthread_mutex_init (&scm_i_define_mutex, NULL);
+
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);
(file #17118)
_______________________________________________________
Additional Item Attachment:
File name: define-race.patch Size:1 KB
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?24867>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [bug #24867] `define' should be thread-safe,
Linas Vepstas <=