From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?utf-8?Q?Cl=C3=A9ment?= Lassieur Newsgroups: gmane.lisp.guile.devel Subject: Re: crashes with Fibers Date: Mon, 02 Jul 2018 11:22:32 +0200 Message-ID: <87lgau2drb.fsf@lassieur.org> References: <8736x63q5v.fsf@lassieur.org> <7d8d11cf58d7adba2ca826c7e58bddde@hypermove.net> <87muvb2jd2.fsf@lassieur.org> <43f3442d6a3b2e18db597b2df68bf8da@hypermove.net> <4995bab49d42634968d6029bc595b2aa@hypermove.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1530523373 25397 195.159.176.226 (2 Jul 2018 09:22:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 2 Jul 2018 09:22:53 +0000 (UTC) User-Agent: mu4e 1.0; emacs 26.1 Cc: guile-devel , guile-devel@gnu.org To: Amirouche Boubekki Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Jul 02 11:22:49 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 1fZv2m-0006Ve-GT for guile-devel@m.gmane.org; Mon, 02 Jul 2018 11:22:48 +0200 Original-Received: from localhost ([::1]:59601 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZv4t-0001ah-Sg for guile-devel@m.gmane.org; Mon, 02 Jul 2018 05:24:59 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:37883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZv3h-0001RB-Nt for guile-devel@gnu.org; Mon, 02 Jul 2018 05:24:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fZv2d-0004JX-K6 for guile-devel@gnu.org; Mon, 02 Jul 2018 05:23:45 -0400 Original-Received: from mail.lassieur.org ([83.152.10.219]:59844) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fZv2d-0004Fa-7l; Mon, 02 Jul 2018 05:22:39 -0400 Original-Received: from rodion (88.191.118.83 [88.191.118.83]) by mail.lassieur.org (OpenSMTPD) with ESMTPSA id 58f2cb37 (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO); Mon, 2 Jul 2018 09:22:33 +0000 (UTC) In-reply-to: <4995bab49d42634968d6029bc595b2aa@hypermove.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 83.152.10.219 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:19578 Archived-At: Hi Amirouche, Amirouche Boubekki writes: >> You test5 code should definitly work. Otherwise, it requires to pre-allocate >> as many thread as you need before you know you will them. May be we can look >> at it backward and say, that allocating a pool of threads in advance is more >> interesting performance wise. But the cost of allocating a thread pool is very small compared to the cost of a doing git clone, which may take a minute or so. >>> Anyway, try to spawn the thread and/or create the channel before you >>> run fibers. I can't try that myself because of my slow connection which >>> takes ages to install guile-fibers. I can't do that because in the program I'm working on (Cuirass), the first calls to RUN-FIBERS and SPAWN-FIBER happen very early[1]. They are kind of the entry point of the program. At that time I don't know how many repositories I will need to fetch simultaneously. Thus test3 and test6 don't meet my needs. [1]: https://git.savannah.gnu.org/cgit/guix/guix-cuirass.git/tree/bin/cuirass.in#n144 >>> Something like: >> >> (use-modules (fibers)) >> (use-modules (fibers channels)) >> >>> (define (test6) >>> (let ((channel (make-channel))) >>> (call-with-new-thread >>> (lambda () >>> (put-message channel "hello world"))) >>> (run-fibers >>> (lambda () >>> (spawn-fiber >>> (lambda () >>> (format #t "~a~%" (get-message channel))))) >>> #:drain? #t))) >> >> It works on my side. > > FWIW, the following code doesn't crash, but apparently does nothing: > > (define (test7) > (let ((channel (make-channel))) > (run-fibers > (lambda () > (spawn-fiber > (lambda () > (call-with-new-thread > (lambda () > (put-message channel "hello world"))) > (format #t "~a~%" (get-message channel))))) > #:drain? #t))) This crashes the same way test5 does, you need to run it more :-)