summaryrefslogtreecommitdiff
path: root/libguile/vm-i-system.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2008-10-09 14:44:43 +0200
committerAndy Wingo <wingo@pobox.com>2008-10-09 14:44:43 +0200
commit66db076ae17e1a6b5225fabaaeb6958115cc9b4c (patch)
treea2390479cac342ab6de5d38aa9492648afe74f16 /libguile/vm-i-system.c
parent0570c3f197f910cc136969d6a2ed2ad0792b3501 (diff)
downloadguile-66db076ae17e1a6b5225fabaaeb6958115cc9b4c.tar.gz
NULLSTACK fixes for nonlocal exits in reentrant pre-wind handlers
* libguile/vm-i-system.c (goto/cc): Add some asserts here. * libguile/vm.c (capture_vm_cont): Add some asserts here too. (reinstate_vm_cont): Null the correct number of bytes. Add a FIXME. (vm_reset_stack): Make the code a bit clearer. Null the correct number of bytes. * libguile/vm-engine.h (NULLSTACK_FOR_NONLOCAL_EXIT): New macro, handles a very tricky case that took me days to find! Amply commented. Expands to nothing in the normal case. * libguile/vm-i-system.c (call, goto/args, mv-call): Call NULLSTACK_FOR_NONLOCAL_EXIT in the right places. Fixes continuations.test.
Diffstat (limited to 'libguile/vm-i-system.c')
-rw-r--r--libguile/vm-i-system.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libguile/vm-i-system.c b/libguile/vm-i-system.c
index e336e4215..33503f290 100644
--- a/libguile/vm-i-system.c
+++ b/libguile/vm-i-system.c
@@ -567,6 +567,7 @@ VM_DEFINE_INSTRUCTION (call, "call", 1, -1, 1)
SYNC_REGISTER ();
/* keep args on stack so they are marked */
sp[-1] = scm_apply (x, sp[0], SCM_EOL);
+ NULLSTACK_FOR_NONLOCAL_EXIT ();
/* FIXME what if SCM_VALUESP(*sp) */
DROP ();
NEXT;
@@ -754,6 +755,7 @@ VM_DEFINE_INSTRUCTION (goto_args, "goto/args", 1, -1, 1)
POP_LIST (nargs);
SYNC_REGISTER ();
sp[-1] = scm_apply (x, sp[0], SCM_EOL);
+ NULLSTACK_FOR_NONLOCAL_EXIT ();
DROP ();
/* FIXME what if SCM_VALUESP(*sp) */
goto vm_return;
@@ -822,6 +824,7 @@ VM_DEFINE_INSTRUCTION (mv_call, "mv-call", 3, -1, 1)
POP_LIST (nargs);
SYNC_REGISTER ();
sp[-1] = scm_apply (x, sp[0], SCM_EOL);
+ NULLSTACK_FOR_NONLOCAL_EXIT ();
DROP ();
if (SCM_VALUESP (*sp))
{
@@ -931,6 +934,9 @@ VM_DEFINE_INSTRUCTION (goto_cc, "goto/cc", 0, 1, 1)
POP (proc);
SYNC_ALL ();
cont = scm_make_continuation (&first);
+ ASSERT (sp == vp->sp);
+ ASSERT (fp == vp->fp);
+ ASSERT (ip == vp->ip);
if (first)
{
PUSH (proc);