mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-16 08:40:19 +02:00
Unwind-only stack overflow exceptions
* module/ice-9/boot-9.scm (catch): Signal an early error if the handler or pre-unwind handler types aren't right. This is more important than it was, given that we dispatch on type now when finding matching catch clauses. * libguile/vm.c (vm_expand_stack): Use the standard scm_report_stack_overflow to signal stack overflow. This will avoid running pre-unwind handlers. * libguile/throw.h: Move scm_report_stack_overflow here. * libguile/throw.c (catch): Define a version of catch in C. (throw_without_pre_unwind): New helper. Besides serving as the pre-boot "throw" binding, it allows stack overflow to throw without running pre-unwind handlers. (scm_catch, scm_catch_with_pre_unwind_handler) (scm_with_throw_handler): Use the new catch in C. (scm_report_stack_overflow): Moved from stackchk.c; throws an unwind-only exception. * libguile/stackchk.h: * libguile/stackchk.c: Remove the scm_report_stack_overflow bits.
This commit is contained in:
parent
5d20fd49fe
commit
7e2fd4e7f5
6 changed files with 181 additions and 155 deletions
|
@ -1016,13 +1016,7 @@ vm_expand_stack (struct scm_vm *vp)
|
|||
old_stack = vp->stack_base;
|
||||
new_stack = expand_stack (vp->stack_base, vp->stack_size, new_size);
|
||||
if (!new_stack)
|
||||
/* It would be nice to throw an exception here, but that is
|
||||
extraordinarily hard. Exceptionally hard, you might say!
|
||||
"throw" is implemented in Scheme, and there may be arbitrary
|
||||
pre-unwind handlers that push on more frames. We will
|
||||
endeavor to do so in the future, but for now we just
|
||||
abort. */
|
||||
abort ();
|
||||
scm_report_stack_overflow ();
|
||||
|
||||
vp->stack_base = new_stack;
|
||||
vp->stack_size = new_size;
|
||||
|
@ -1068,6 +1062,8 @@ vm_expand_stack (struct scm_vm *vp)
|
|||
/* Finally, reset the limit, to catch further overflows. */
|
||||
vp->stack_limit = vp->stack_base + vp->max_stack_size;
|
||||
|
||||
/* FIXME: Use scm_report_stack_overflow, but in a mode that allows
|
||||
pre-unwind handlers to run. */
|
||||
vm_error ("VM: Stack overflow", SCM_UNDEFINED);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue