diff options
author | Andy Wingo <wingo@pobox.com> | 2014-02-20 09:45:01 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2014-02-20 09:45:01 +0100 |
commit | 7e2fd4e7f53c281307efd12b80df46346002a33d (patch) | |
tree | 324241c65afa58b0b1f75600716b69e932bd4334 /libguile/vm.c | |
parent | 5d20fd49fe53c2520e36e8bf983c7b7214b0ad2a (diff) | |
download | guile-7e2fd4e7f53c281307efd12b80df46346002a33d.tar.gz |
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.
Diffstat (limited to 'libguile/vm.c')
-rw-r--r-- | libguile/vm.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/libguile/vm.c b/libguile/vm.c index b071a54cb..db1309432 100644 --- a/libguile/vm.c +++ b/libguile/vm.c @@ -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); } |