From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Re: [Guile-commits] GNU Guile branch, master, updated. v2.1.0-213-gb43e81d Date: Fri, 04 Oct 2013 00:20:46 -0400 Message-ID: <87bo35bra9.fsf@netris.org> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1380860497 8483 80.91.229.3 (4 Oct 2013 04:21:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 4 Oct 2013 04:21:37 +0000 (UTC) Cc: guile-devel@gnu.org To: "Andy Wingo" Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Oct 04 06:21:40 2013 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VRwtX-0005Jr-QJ for guile-devel@m.gmane.org; Fri, 04 Oct 2013 06:21:39 +0200 Original-Received: from localhost ([::1]:46252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRwtX-0000bL-DW for guile-devel@m.gmane.org; Fri, 04 Oct 2013 00:21:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRwtO-0000b8-L7 for guile-devel@gnu.org; Fri, 04 Oct 2013 00:21:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VRwtI-0002qU-V2 for guile-devel@gnu.org; Fri, 04 Oct 2013 00:21:30 -0400 Original-Received: from world.peace.net ([96.39.62.75]:58822) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRwtI-0002U3-R7 for guile-devel@gnu.org; Fri, 04 Oct 2013 00:21:24 -0400 Original-Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=yeeloong) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1VRwt1-0003R7-EW; Fri, 04 Oct 2013 00:21:07 -0400 In-Reply-To: (Andy Wingo's message of "Thu, 03 Oct 2013 20:48:24 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 96.39.62.75 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:16667 Archived-At: Hi Andy, "Andy Wingo" writes: > diff --git a/libguile/programs.c b/libguile/programs.c > index 37130d0..5039d2a 100644 > --- a/libguile/programs.c > +++ b/libguile/programs.c > @@ -297,7 +297,7 @@ SCM_DEFINE (scm_program_bindings, "program-bindings", 1, 0, 0, > } > #undef FUNC_NAME > > -SCM_DEFINE (scm_program_sources, "program-sources", 1, 0, 0, > +SCM_DEFINE (scm_program_sources, "%program-sources", 1, 0, 0, > (SCM program), > "") > #define FUNC_NAME s_scm_program_sources > @@ -365,32 +365,24 @@ scm_i_program_properties (SCM program) > } > #undef FUNC_NAME > > -static SCM > -program_source (SCM program, size_t ip, SCM sources) > +SCM > +scm_program_source (SCM program, SCM ip, SCM sources) > { > - SCM source = SCM_BOOL_F; > + static SCM program_source = SCM_BOOL_F; > > - while (!scm_is_null (sources) > - && scm_to_size_t (scm_caar (sources)) <= ip) > - { > - source = scm_car (sources); > - sources = scm_cdr (sources); > - } > - > - return source; /* (addr . (filename . (line . column))) */ > -} > + if (scm_is_false (program_source)) { > + if (!scm_module_system_booted_p) > + return SCM_BOOL_F; > + > + program_source = > + scm_c_private_variable ("system vm program", "program-source"); > + } This lazy initialization pattern is not safe on modern weakly ordered memory architectures. I've already raised this issue on the mailing list more than once, and I've been trying to fix these bugs wherever I can find them, but they are non-trivial to search for. Please do not add more. We need to either use a mutex to guard both reads and writes of 'program_source' (including the "scm_is_false (program_source)" check), or we need to arrange for 'program_source' to be initialized during guile's initialization before any other threads are created. Mark