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

Raise an exception upon VM stack overflows (fixes bug #29574).

* libguile/vm-engine.c (VM_NAME)[vm_error_stack_overflow]: Increase
  `vp->stack_limit' when possible.

* libguile/vm.c (VM_STACK_RESERVE_SIZE): New macro.

* test-suite/lib.scm (exception:vm-error): New variable.

* test-suite/tests/eval.test ("stack overflow"): New test prefix.
This commit is contained in:
Ludovic Courtès 2010-05-26 23:00:58 +02:00
parent 01fded8c77
commit f1046e6b78
4 changed files with 26 additions and 3 deletions

View file

@ -65,6 +65,10 @@
for a discussion. */
#define VM_ENABLE_PRECISE_STACK_GC_SCAN
/* Size in SCM objects of the stack reserve. The reserve is used to run
exception handling code in case of a VM stack overflow. */
#define VM_STACK_RESERVE_SIZE 512
/*
@ -505,7 +509,7 @@ make_vm (void)
#ifdef VM_ENABLE_STACK_NULLING
memset (vp->stack_base, 0, vp->stack_size * sizeof (SCM));
#endif
vp->stack_limit = vp->stack_base + vp->stack_size;
vp->stack_limit = vp->stack_base + vp->stack_size - VM_STACK_RESERVE_SIZE;
vp->ip = NULL;
vp->sp = vp->stack_base - 1;
vp->fp = NULL;
@ -534,8 +538,7 @@ vm_stack_mark (GC_word *addr, struct GC_ms_entry *mark_stack_ptr,
vm = * ((struct scm_vm **) addr);
if (vm == NULL
|| (SCM *) addr != vm->stack_base - 1
|| vm->stack_limit - vm->stack_base != vm->stack_size)
|| (SCM *) addr != vm->stack_base - 1)
/* ADDR must be a pointer to a free-list element, which we must ignore
(see warning in <gc/gc_mark.h>). */
return mark_stack_ptr;