I was experimenting with system-async-mark and found the problem with condition variables. I guess it happens because when async does non-local exit, the thread can not be removed from condition variable waiters and signaling fiber is hanging indefinitely.
The following code hangs on signal-condition! invocation:
(begin
(format #t "\n\n====================\n")
(use-modules (fibers) (fibers conditions) (ice-9 threads)
(fibers channels))
(define cnd (make-condition))
(define ch (make-channel))
(define mutex (make-mutex 'allow-external-unlock))
(lock-mutex mutex)
(define prompt (make-prompt-tag "tmp"))
(define th (call-with-new-thread
(lambda ()
(call-with-prompt prompt
(lambda ()
(format #t "-> inside prompt\n")
;; (lock-mutex mutex)
(wait cnd)
(format #t "-> condition unlcoked\n"))
(lambda (k . args)
(apply values args)))
(format #t "<- after prompt\n")
;; (wait cnd)
;; (lock-mutex mutex)
(format #t "<- finishing\n"))))
(sleep 1)
(format #t "substituting computation\n")
(system-async-mark
(lambda ()
(put-message ch 'hello)
(abort-to-prompt prompt)) th)
(run-fibers (lambda ()
(format #t "message: ~a\n" (get-message ch))
;; (unlock-mutex mutex)
(signal-condition! cnd)
(format #t "!condition signalled\n"))
#:drain? #f)
(sleep 1)
(format #t "after lock\n")
(format #t "--------------------\n")
(sleep 3) "")
The output is following:
====================
-> inside prompt
substituting computation
message: hello
<- after prompt
<- finishing