From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: Using define in multiple threads? Date: Tue, 18 Nov 2008 11:20:41 +0100 Message-ID: <87od0dl4hy.fsf@gnu.org> References: <3ae3aa420811161427t6b2c65d1q4adcd6e9a5689ddc@mail.gmail.com> <87od0ee6yl.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1227003705 24125 80.91.229.12 (18 Nov 2008 10:21:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Nov 2008 10:21:45 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Nov 18 11:22:47 2008 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L2NjF-0003Xg-Qs for guile-devel@m.gmane.org; Tue, 18 Nov 2008 11:22:42 +0100 Original-Received: from localhost ([127.0.0.1]:35483 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L2Ni7-0001fp-6U for guile-devel@m.gmane.org; Tue, 18 Nov 2008 05:21:31 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L2NhZ-0001Pf-Ep for guile-devel@gnu.org; Tue, 18 Nov 2008 05:20:57 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L2NhX-0001Oz-Kl for guile-devel@gnu.org; Tue, 18 Nov 2008 05:20:56 -0500 Original-Received: from [199.232.76.173] (port=55420 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L2NhX-0001Ow-Ct for guile-devel@gnu.org; Tue, 18 Nov 2008 05:20:55 -0500 Original-Received: from main.gmane.org ([80.91.229.2]:56729 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L2NhX-0000et-0A for guile-devel@gnu.org; Tue, 18 Nov 2008 05:20:55 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1L2NhT-00070k-CC for guile-devel@gnu.org; Tue, 18 Nov 2008 10:20:51 +0000 Original-Received: from dhcpr-239.futurs.inria.fr ([195.83.212.239]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 18 Nov 2008 10:20:51 +0000 Original-Received: from ludo by dhcpr-239.futurs.inria.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 18 Nov 2008 10:20:51 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 34 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: dhcpr-239.futurs.inria.fr X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 28 Brumaire an 217 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 821D 815D 902A 7EAB 5CEE D120 7FBA 3D4F EB1F 5364 X-OS: i686-pc-linux-gnu User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux) Cancel-Lock: sha1:h5dGO0V9XufLoiSQ4j0GTGEXn0E= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:7860 Archived-At: Andy Wingo writes: > On Mon 17 Nov 2008 15:57, ludo@gnu.org (Ludovic Courtès) writes: >> Besides, as Linas noted, the hash table implementation isn't >> thread-safe, which makes it "unsafe" to `define' in parallel. > > Ah, this is why, then. I was baffled. > > IMO this is a bug; Guile can claim that "wierd behavior is expected" > when using a data structure from multiple threads in without locking, > but in this case the data structure is only being used implicitly. > Modules should contain a lock that is taken when they are mutated. Right. I submitted a bug: https://savannah.gnu.org/bugs/index.php?24867 . I'm not sure whether this can easily be fixed in 1.8, since that would require adding a mutex to `module-type' and access it from C, which would break the ABI. Ideas? > This isn't the first time I've wanted a functional hash table > implementation... I wrote long ago an implementation of functional FIFOs and one of Bagwell's "VLists" [0]; VLists can be used at a building block for "hash lists", which is a functional data structure akin to hash tables [0]. I've been willing to polish it and push it into Guile for some time, so if you're motivated, that's even more motivating. :-) Thanks, Ludo'. [0] http://en.wikipedia.org/wiki/VList