From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Linas Vepstas Newsgroups: gmane.lisp.guile.bugs Subject: [bug #24867] `define' should be thread-safe Date: Tue, 23 Dec 2008 02:36:13 +0000 Message-ID: <20081223-023612.sv71519.31021@savannah.gnu.org> References: <20081118-101829.sv15145.66129@savannah.gnu.org> <20081118-132731.sv15145.42938@savannah.gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain;charset=UTF-8 X-Trace: ger.gmane.org 1229999798 17584 80.91.229.12 (23 Dec 2008 02:36:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 23 Dec 2008 02:36:38 +0000 (UTC) To: Andy Wingo , Ludovic =?UTF-8?B?Q291cnTDqHM=?= , Linas Vepstas , bug-guile@gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Tue Dec 23 03:37:43 2008 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LEx9S-0001ea-1b for guile-bugs@m.gmane.org; Tue, 23 Dec 2008 03:37:42 +0100 Original-Received: from localhost ([127.0.0.1]:50410 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LEx8F-00016K-2q for guile-bugs@m.gmane.org; Mon, 22 Dec 2008 21:36:27 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LEx8A-000161-3c for bug-guile@gnu.org; Mon, 22 Dec 2008 21:36:22 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LEx89-00015p-36 for bug-guile@gnu.org; Mon, 22 Dec 2008 21:36:21 -0500 Original-Received: from [199.232.76.173] (port=56572 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LEx88-00015m-J0 for bug-guile@gnu.org; Mon, 22 Dec 2008 21:36:20 -0500 Original-Received: from savannah.gnu.org ([199.232.41.3]:45455 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LEx87-0005Uh-A4; Mon, 22 Dec 2008 21:36:19 -0500 Original-Received: from [10.0.0.103] (helo=savannah.gnu.org) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LEx81-0000r4-PS; Tue, 23 Dec 2008 02:36:14 +0000 Original-Received: from www-data by savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LEx81-0000r1-GH; Tue, 23 Dec 2008 02:36:13 +0000 X-Savane-Server: savannah.gnu.org:443 [199.232.41.3] X-Savane-Project: guile X-Savane-Tracker: bugs X-Savane-Item-ID: 24867 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 X-Apparently-From: 67.100.217.179 (Savane authenticated user linas) In-Reply-To: <20081118-132731.sv15145.42938@savannah.gnu.org> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:4145 Archived-At: 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 --- 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: _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/