You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in both current master and 1.0.0 this will cause a hang - run-fibers doesn't return, and it doesn't do anything either (in current master it will actually be an uninterruptible hang - ^C'ing won't do anything because of the catch-loop in run-scheduler (unless you manage to press it again before catch is re-entered)). The reason for this is that the ret atomic box doesn't get written to when the init thunk throws an exception. Thus, finished? always returns #f. It's also currently possible for an exception from init to cause the main scheduler to never be woken up, as that spawn-fiber invocation is skipped.
Since we're already ensuring that the return value of the initial thunk gets passed along to the caller, we should probably ensure that any exceptions do as well. We could do this by wrapping the result such that an exception with arguments args becomes (list 'err args) and a regular exit with return values vals becomes (list 'ok vals). We then match on the first symbol when deciding at the end of run-fibers whether to return or re-throw.
The code below fixes the hang-on-exception behavior and also ensures that the main scheduler gets woken up even if an exception is thrown. It also re-throws the exception in the caller's context.
Consider the following:
in both current master and 1.0.0 this will cause a hang -
run-fibers
doesn't return, and it doesn't do anything either (in current master it will actually be an uninterruptible hang - ^C'ing won't do anything because of the catch-loop inrun-scheduler
(unless you manage to press it again beforecatch
is re-entered)). The reason for this is that theret
atomic box doesn't get written to when theinit
thunk throws an exception. Thus,finished?
always returns#f
. It's also currently possible for an exception frominit
to cause the main scheduler to never be woken up, as thatspawn-fiber
invocation is skipped.Since we're already ensuring that the return value of the initial thunk gets passed along to the caller, we should probably ensure that any exceptions do as well. We could do this by wrapping the result such that an exception with arguments
args
becomes(list 'err args)
and a regular exit with return valuesvals
becomes(list 'ok vals)
. We then match on the first symbol when deciding at the end ofrun-fibers
whether to return or re-throw.The code below fixes the hang-on-exception behavior and also ensures that the main scheduler gets woken up even if an exception is thrown. It also re-throws the exception in the caller's context.
The text was updated successfully, but these errors were encountered: