unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: "Clément Lassieur" <clement@lassieur.org>
To: guile-devel@gnu.org
Subject: crashes with Fibers
Date: Fri, 29 Jun 2018 11:20:12 +0200	[thread overview]
Message-ID: <8736x63q5v.fsf@lassieur.org> (raw)

Hi,

I'm encountering a few crashes with Fibers that happen when I call
CALL-WITH-NEW-THREAD in a Fiber.  TEST4 crashes every time.  TEST5 never
outputs, but it doesn't crash every time.

TEST1 is exactly like TEST5 except that I replace CALL-WITH-NEW-THREAD
with SPAWN-FIBER.

Is it a mistake from me or a Guile bug?  If it is a bug, do you know if
there are workarounds?

Thank you,
Clément

    (use-modules (fibers channels)
                 (fibers))

    ;; good
    (define (test1)
      (run-fibers
       (lambda ()
         (spawn-fiber
          (lambda ()
            (let ((channel (make-channel)))
              (spawn-fiber
               (lambda ()
                 (put-message channel "hello world")))
              (format #t "~a~%" (get-message channel))))))
       #:drain? #t))
    ⊣ hello world

    ;; good
    (define (test2)
      (let ((channel (make-channel)))
        (call-with-new-thread
         (lambda ()
           (put-message channel "hello world")))
        (format #t "~a~%" (get-message channel))))
    ⊣ hello world
    ⇒ #t

    ;; good
    (define (test3)
      (run-fibers
       (lambda ()
         (let ((channel (make-channel)))
           (call-with-new-thread
            (lambda ()
              (put-message channel "hello world")))
           (format #t "~a~%" (get-message channel))))
       #:drain? #t))
    ⊣ hello world
    ⇒ #t

    ;; 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

    ;; bad
    (define (test5)
      (run-fibers
       (lambda ()
         (spawn-fiber
          (lambda ()
            (let ((channel (make-channel)))
              (call-with-new-thread
               (lambda ()
                 (put-message channel "hello world")))
              (format #t "~a~%" (get-message channel))))))
       #:drain? #t))
    ⊣ scheme@(guile-user)> In /home/clement/.guix-profile/share/guile/site/2.2/fibers/operations.scm:
          188:5  3 (perform-operation #<<base-op> wrap-fn: #f try-fn: #<procedure try-fn ()> block-fn: #<procedure block-fn (put-flag put-sched resume-put)>>)
      In /home/clement/.guix-profile/share/guile/site/2.2/fibers/channels.scm:
          88:26  2 (try-fn)
      In /home/clement/.guix-profile/share/guile/site/2.2/fibers/internal.scm:
          219:6  1 (schedule-fiber! _ _)
      In unknown file:
                 0 (scm-error misc-error #f "~A" ("epoll instance is dead") #f)
      ERROR: In procedure scm-error:
      epoll instance is dead



             reply	other threads:[~2018-06-29  9:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-29  9:20 Clément Lassieur [this message]
2018-07-01 11:16 ` crashes with Fibers 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
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=8736x63q5v.fsf@lassieur.org \
    --to=clement@lassieur.org \
    --cc=guile-devel@gnu.org \
    /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).