From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: crashes with Fibers Date: Mon, 02 Jul 2018 11:32:50 +0200 Message-ID: <87sh52j83h.fsf@gnu.org> References: <8736x63q5v.fsf@lassieur.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1530524120 14950 195.159.176.226 (2 Jul 2018 09:35:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 2 Jul 2018 09:35:20 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Jul 02 11:35:15 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 1fZvEp-0003nL-6c for guile-devel@m.gmane.org; Mon, 02 Jul 2018 11:35:15 +0200 Original-Received: from localhost ([::1]:59647 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZvGw-0005AS-Il for guile-devel@m.gmane.org; Mon, 02 Jul 2018 05:37:26 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42913) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZvGr-0005A6-T0 for guile-devel@gnu.org; Mon, 02 Jul 2018 05:37:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fZvGm-00060O-WD for guile-devel@gnu.org; Mon, 02 Jul 2018 05:37:21 -0400 Original-Received: from [195.159.176.226] (port=36237 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fZvGm-0005zi-Oy for guile-devel@gnu.org; Mon, 02 Jul 2018 05:37:16 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fZvEd-0003Zl-98 for guile-devel@gnu.org; Mon, 02 Jul 2018 11:35:03 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 41 Original-X-Complaints-To: usenet@blaine.gmane.org X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 14 Messidor an 226 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Cancel-Lock: sha1:9NYrif+lXMDAiH8GwYWSwJj/GXU= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 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:19580 Archived-At: Hello Clément, Clément Lassieur skribis: > ;; bad > (define (test4) > (run-fibers > (lambda () > (spawn-fiber > (lambda () > (let ((channel (make-channel))) > (call-with-new-thread > (lambda () > (put-message channel "hello world"))))))) > #:drain? #t)) > ⊣ scheme@(guile-user)> In /home/clement/.guix-profile/share/guile/site/2.2/fibers/internal.scm: > 402:6 1 (suspend-current-fiber _) > In unknown file: > 0 (scm-error misc-error #f "~A" ("Attempt to suspend fiber within continuation barrier") #f) > ERROR: In procedure scm-error: > Attempt to suspend fiber within continuation barrier I think the problem here is that the new thread inherit the dynamic environment of the spawning thread. Thus, ‘put-message’, called in that new thread, thinks it’s running within a Fiber, but it’s not. Because of that, ‘put-message’ tries to suspend itself, but it cannot: ‘call-with-new-thread’ is written in C, so it’s a “continuation barrier” (meaning that it’s a continuation that cannot be captured and resumed later.) So I think if you really want that, you can perhaps do something like (untested): (call-with-new-thread (lambda () (parameterize ((current-fiber #f)) (put-message channel "hello world")))) HTH! Ludo’.