1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-21 03:00:19 +02:00

Fix exn dispatch for exns within pre-unwind handlers

* libguile/exceptions.c (exception_epoch_fluid): Rename from
active_exception_handlers_fluid.
(scm_dynwind_throw_handler): Increment exception epoch instead of
resetting active exception handlers.
(scm_init_exceptions): Update.
* module/ice-9/boot-9.scm  (with-exception-handler): Rework to associate
an "epoch" fluid with each exception handler.
(with-throw-handler): Establish a new epoch, during the execution of a
throw handler.
(raise-exception): Rework to avoid capturing a list of exception
handlers, and to use epochs as a way to know which handlers have already
been examined and which are on the dispatch stack.
* test-suite/tests/exceptions.test ("throwing within exception
handlers"): New test.
This commit is contained in:
Andy Wingo 2023-06-07 22:26:05 +02:00
parent ee18ca9a35
commit 02dfb6e776
3 changed files with 81 additions and 46 deletions

View file

@ -17,6 +17,7 @@
(define-module (test-suite exceptions)
#:use-module (ice-9 control)
#:use-module (test-suite lib))
(define-syntax-parameter push
@ -392,3 +393,14 @@
(let* ((thunk1 (catch* 'foo (lambda () (throw 'bar))))
(thunk2 (catch* 'bar (lambda () (thunk1)))))
(thunk2))))
(with-test-prefix "throwing within exception handlers"
(pass-if "https://github.com/wingo/fibers/issues/76"
(let/ec return
(with-exception-handler
(lambda (e)
(catch #t
(lambda () (error "bar"))
(lambda args #f))
(return #t))
(lambda () (error "foo"))))))