error if given an unrewindable partial continuation
authorAndy Wingo <wingo@pobox.com>
Wed, 24 Feb 2010 23:18:07 +0000 (00:18 +0100)
committerAndy Wingo <wingo@pobox.com>
Wed, 24 Feb 2010 23:43:51 +0000 (00:43 +0100)
* libguile/vm-engine.c (vm_error_continuation_not_rewindable):
* libguile/vm-i-system.c (partial-cont-call):
* libguile/vm.h (SCM_VM_CONT_PARTIAL_P):
  (SCM_VM_CONT_REWINDABLE_P): Fix a bug in which we weren't checking if
  a partial continuation was actually rewindable.

libguile/vm-engine.c
libguile/vm-i-system.c
libguile/vm.h

index 8c188d3..1976f71 100644 (file)
@@ -233,6 +233,11 @@ VM_NAME (SCM vm, SCM program, SCM *argv, int nargs)
     finish_args = SCM_EOL;
     goto vm_error;
 
+  vm_error_continuation_not_rewindable:
+    err_msg  = scm_from_locale_string ("Unrewindable partial continuation");
+    finish_args = scm_cons (finish_args, SCM_EOL);
+    goto vm_error;
+
   vm_error_bad_wide_string_length:
     err_msg  = scm_from_locale_string ("VM: Bad wide string length: ~S");
     goto vm_error;
index 04ef951..56df727 100644 (file)
@@ -999,6 +999,10 @@ VM_DEFINE_INSTRUCTION (94, partial_cont_call, "partial-cont-call", 0, -1, 0)
   POP (intwinds);
   POP (vmcont);
   SYNC_REGISTER ();
+  if (SCM_UNLIKELY (!SCM_VM_CONT_REWINDABLE_P (vmcont)))
+    { finish_args = vmcont;
+      goto vm_error_continuation_not_rewindable;
+    }
   vm_reinstate_partial_continuation (vm, vmcont, intwinds, sp + 1 - fp, fp);
   CACHE_REGISTER ();
   program = SCM_FRAME_PROGRAM (fp);
index 48e0bb6..ade4bb6 100644 (file)
@@ -102,8 +102,8 @@ struct scm_vm_cont {
 
 #define SCM_VM_CONT_P(OBJ)     (SCM_NIMP (OBJ) && SCM_TYP7 (OBJ) == scm_tc7_vm_cont)
 #define SCM_VM_CONT_DATA(CONT) ((struct scm_vm_cont *) SCM_CELL_WORD_1 (CONT))
-#define SCM_VM_CONT_PARTIAL_P(CONT) (SCM_VM_CONT_DATA (CONT) & SCM_F_VM_CONT_PARTIAL)
-#define SCM_VM_CONT_REWINDABLE_P(CONT) (SCM_VM_CONT_DATA (CONT) & SCM_F_VM_CONT_REWINDABLE)
+#define SCM_VM_CONT_PARTIAL_P(CONT) (SCM_VM_CONT_DATA (CONT)->flags & SCM_F_VM_CONT_PARTIAL)
+#define SCM_VM_CONT_REWINDABLE_P(CONT) (SCM_VM_CONT_DATA (CONT)->flags & SCM_F_VM_CONT_REWINDABLE)
 
 SCM_API SCM scm_load_compiled_with_vm (SCM file);