From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.bugs Subject: bug#30261: segfault on simultaneous initialization Date: Sat, 27 Jan 2018 15:27:21 -0500 Message-ID: <87vafnoxna.fsf@netris.org> References: <87mv10kx2i.fsf@netris.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1517084854 11273 195.159.176.226 (27 Jan 2018 20:27:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 27 Jan 2018 20:27:34 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) Cc: "30261@debbugs.gnu.org" <30261@debbugs.gnu.org> To: Sheheryar Parvaz Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sat Jan 27 21:27:29 2018 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1efX4B-0001ZL-Vj for guile-bugs@m.gmane.org; Sat, 27 Jan 2018 21:27:12 +0100 Original-Received: from localhost ([::1]:42165 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efX6B-0006Ek-6A for guile-bugs@m.gmane.org; Sat, 27 Jan 2018 15:29:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efX62-0006DC-0u for bug-guile@gnu.org; Sat, 27 Jan 2018 15:29:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1efX5y-0008FS-38 for bug-guile@gnu.org; Sat, 27 Jan 2018 15:29:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37621) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1efX5x-0008FJ-VJ for bug-guile@gnu.org; Sat, 27 Jan 2018 15:29:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1efX5x-0007c4-Oz for bug-guile@gnu.org; Sat, 27 Jan 2018 15:29:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 27 Jan 2018 20:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30261 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 30261-submit@debbugs.gnu.org id=B30261.151708488229166 (code B ref 30261); Sat, 27 Jan 2018 20:29:01 +0000 Original-Received: (at 30261) by debbugs.gnu.org; 27 Jan 2018 20:28:02 +0000 Original-Received: from localhost ([127.0.0.1]:45518 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1efX4z-0007aH-S3 for submit@debbugs.gnu.org; Sat, 27 Jan 2018 15:28:02 -0500 Original-Received: from world.peace.net ([50.252.239.5]:49942) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1efX4y-0007a3-AL for 30261@debbugs.gnu.org; Sat, 27 Jan 2018 15:28:00 -0500 Original-Received: from pool-72-93-27-251.bstnma.east.verizon.net ([72.93.27.251] helo=jojen) by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1efX4s-0000kl-1c; Sat, 27 Jan 2018 15:27:54 -0500 In-Reply-To: (Sheheryar Parvaz's message of "Sat, 27 Jan 2018 00:58:06 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:8986 Archived-At: Sheheryar Parvaz wrote: > If the initial call to scm_with_guile is on a thread and in the main > thread at the same time, a segmentation fault occurs. Mark H Weaver wrote: > Yes, this is a known issue. At present, Guile must be fully initialized > in one thread before it can be safely used from any other thread. > Furthermore, when loading modules, you must ensure that no other thread > attempts to load or use the same module while it's being loaded. If > possible, please arrange to load all modules that your program will need > before accessing Guile from other threads. Sheheryar Parvaz writes: > Are there any decent workarounds for this? I considered > scm_init_guile, however according to the documentation, it is > non-portable. For modules, I have no idea how I would initialize them. The usual approach is to initialize Guile before spawning any other threads. You can do this by calling 'scm_with_guile' early in your 'main', and then moving most of the contents of your 'main' into the inner function that 'scm_with_guile' calls. If there are modules that you'll need to load from your threaded code, then load them before spawning any threads, from within the inner function that 'scm_with_guile' calls. From C, you can load modules with 'scm_c_resolve_module'. Mark