From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chris Vine Newsgroups: gmane.lisp.guile.user Subject: libguile thread safety Date: Fri, 3 Jan 2014 23:34:07 +0000 Message-ID: <20140103233407.36382e5f@bother.homenet> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1388792063 28739 80.91.229.3 (3 Jan 2014 23:34:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 3 Jan 2014 23:34:23 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Jan 04 00:34:30 2014 Return-path: Envelope-to: guile-user@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 1VzEG3-0002ha-Ml for guile-user@m.gmane.org; Sat, 04 Jan 2014 00:34:27 +0100 Original-Received: from localhost ([::1]:52508 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VzEG2-0005CV-U9 for guile-user@m.gmane.org; Fri, 03 Jan 2014 18:34:26 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VzEFp-0005Bm-4R for guile-user@gnu.org; Fri, 03 Jan 2014 18:34:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VzEFj-0007tr-AW for guile-user@gnu.org; Fri, 03 Jan 2014 18:34:13 -0500 Original-Received: from smtpout1.wanadoo.co.uk ([80.12.242.29]:48063 helo=smtpout.wanadoo.co.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VzEFj-0007tM-3w for guile-user@gnu.org; Fri, 03 Jan 2014 18:34:07 -0500 Original-Received: from bother.homenet ([95.146.112.60]) by mwinf5d07 with ME id 9ba41n0041JEVaP03ba4xi; Sat, 04 Jan 2014 00:34:04 +0100 Original-Received: from bother.homenet (localhost [127.0.0.1]) by bother.homenet (Postfix) with ESMTP id F2BD188504 for ; Fri, 3 Jan 2014 23:34:07 +0000 (GMT) X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.22; i686-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 80.12.242.29 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:10963 Archived-At: Hi, I am having problems using libguile in a multi-threaded environment, which boils down to the following small test case, which fails with a segmentation fault with guile-2.0.9: #include #include void *guile_wrapper (void *data) { scm_c_eval_string ("(display \"Hello\n\")"); return NULL; } void *thread_func (void *data) { scm_with_guile (&guile_wrapper, NULL); return NULL; } int main () { pthread_t thread1; pthread_t thread2; pthread_create (&thread1, NULL, thread_func, NULL); pthread_create (&thread2, NULL, thread_func, NULL); pthread_join (thread1, NULL); pthread_join (thread2, NULL); return 0; } However, it prints "Hello" correctly if only one thread is started. It seems that scm_with_guile() is not thread safe in the form used above. However the following suggest that it should be: http://www.gnu.org/software/guile/manual/html_node/Multi_002dThreading.html#Multi_002dThreading http://www.gnu.org/software/guile/manual/html_node/Initialization.html#Initialization I am clearly doing something wrong, which is probably obvious to others. Can anyone help me with this? Perhaps I have to serialize use of scm_with_guile() notwithstanding what is said in the documentation, but if so it will be disappointing for the use to which I was hoping to put it. Chris