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.devel Subject: Re: (n-for-each-par-map 16 store download (reverse (iota (max-id))))) crash Date: Thu, 05 Jul 2018 14:30:28 -0400 Message-ID: <871schk01n.fsf@netris.org> References: <567d1b31558c2b51908d8a272ff61494@hypermove.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1530815388 32054 195.159.176.226 (5 Jul 2018 18:29:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 5 Jul 2018 18:29:48 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: Guile Devel To: Amirouche Boubekki Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Jul 05 20:29:44 2018 Return-path: Envelope-to: guile-devel@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 1fb90i-0008E2-3r for guile-devel@m.gmane.org; Thu, 05 Jul 2018 20:29:44 +0200 Original-Received: from localhost ([::1]:54341 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fb92p-0005IV-Di for guile-devel@m.gmane.org; Thu, 05 Jul 2018 14:31:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fb92h-0005H8-2E for guile-devel@gnu.org; Thu, 05 Jul 2018 14:31:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fb92d-0006oB-3Q for guile-devel@gnu.org; Thu, 05 Jul 2018 14:31:47 -0400 Original-Received: from world.peace.net ([64.112.178.59]:58456) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fb92c-0006nK-Up for guile-devel@gnu.org; Thu, 05 Jul 2018 14:31:43 -0400 Original-Received: from mhw by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fb92b-0007pZ-Jl; Thu, 05 Jul 2018 14:31:41 -0400 In-Reply-To: <567d1b31558c2b51908d8a272ff61494@hypermove.net> (Amirouche Boubekki's message of "Thu, 05 Jul 2018 13:28:58 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.112.178.59 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.lisp.guile.devel:19585 Archived-At: Hi, Amirouche Boubekki writes: > I have a program that try to download hackernews locally. > > What it does is simple, it fetch the max identifier and > http-get each json value starting with the most recent > item. I use n-for-each-par-map with 16 threads I have > 8 cores. > > Here is the full program: [...] > (define (store pair) > (if (null? pair) > (format #t "X\n") > (let ((port (open-file "hn.scm" "a"))) > (format #t "~a\n" (car pair)) These calls to (format #t ...), which write to a port that is shared by multiple threads, should be performed while holding a mutex to prevent concurrent writes to the same port. I/O operations in Guile do not include built-in thread synchronization, at least not in the fast path cases. However, an effort was made to avoid _crashes_ on common architectures in the event of concurrent use of the same port. Our hope was that the worst that would typically happen is garbled I/O. Perhaps we failed to realize that hope. > How can I debug this? It would be helpful to see a GDB backtrace from a crash in this program. Does it help to protect the shared port with a mutex? Thanks, Mark