unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: "Clément Lassieur" <clement@lassieur.org>
To: Andy Wingo <wingo@igalia.com>
Cc: "Ludovic Courtès" <ludo@gnu.org>, guile-devel@gnu.org
Subject: Re: crashes with Fibers
Date: Tue, 17 Jul 2018 20:16:31 +0200	[thread overview]
Message-ID: <87lga9iv7k.fsf@lassieur.org> (raw)
In-Reply-To: <87in5x3m7m.fsf@lassieur.org>

Clément Lassieur <clement@lassieur.org> writes:

> Ludovic Courtès <ludo@gnu.org> writes:
>
>> Hello Clément,
>>
>> Clément Lassieur <clement@lassieur.org> 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"))))
>
> It works, but only with (@@ (fibers internal) current-fiber) because the
> parameter isn't exported.
>
> Thank you Ludo!

Hi Andy,

I'm adding you to this conversation to notify you about this Fibers
issue.  (I don't have a Github account to report the bug there.)

Thanks,
Clément



  reply	other threads:[~2018-07-17 18:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-29  9:20 crashes with Fibers Clément Lassieur
2018-07-01 11:16 ` Amirouche Boubekki
2018-07-01 13:09   ` Clément Lassieur
2018-07-01 22:32     ` Amirouche Boubekki
2018-07-01 22:41       ` Amirouche Boubekki
2018-07-01 22:46         ` Amirouche Boubekki
2018-07-02  9:22           ` Clément Lassieur
2018-07-02  9:32 ` Ludovic Courtès
2018-07-02 11:34   ` Clément Lassieur
2018-07-17 18:16     ` Clément Lassieur [this message]
2018-07-19 23:50       ` Amirouche Boubekki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lga9iv7k.fsf@lassieur.org \
    --to=clement@lassieur.org \
    --cc=guile-devel@gnu.org \
    --cc=ludo@gnu.org \
    --cc=wingo@igalia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).