]> gitweb.factorcode.org Git - factor.git/commitdiff
VM: moves the code that clears the roots to the same function that
authorBjörn Lindqvist <bjourne@gmail.com>
Wed, 23 Jul 2014 09:07:49 +0000 (11:07 +0200)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 23 Jul 2014 14:12:28 +0000 (07:12 -0700)
corrupts the stack

vm/cpu-x86.cpp
vm/errors.cpp

index 85a8186d9fd013bacf0c62901be353a05f57815d..c436afa57e8990db842e06e2e76ed3808ab8b99b 100644 (file)
@@ -56,6 +56,14 @@ void factor_vm::dispatch_signal_handler(cell* sp, cell* pc, cell handler) {
 
     *pc = (cell)handler_word->entry_point;
   }
+
+  /* Poking with the stack pointer, which the above code does, means
+     that pointers to stack-allocated objects will become
+     corrupted. Therefore the root vectors needs to be cleared because
+     their pointers to stack variables are now garbage. */
+  data_roots.clear();
+  bignum_roots.clear();
+  code_roots.clear();
 }
 
 }
index 7e2a9d077b79bc7adf345f9d0454b2099fadd7f2..6b2a108a2adac6b09ca477c88f17465acd238453 100644 (file)
@@ -39,13 +39,6 @@ void out_of_memory() {
 /* Allocates memory */
 void factor_vm::general_error(vm_error_type error, cell arg1_, cell arg2_) {
 
-  /* If we got here from memory_protection_error(), then the stack
-     pointer has been fiddled with and the elements of these vectors,
-     which address stack-allocated objects, are bogus and needs to be
-     resetted. */
-  data_roots.clear();
-  bignum_roots.clear();
-  code_roots.clear();
 
   data_root<object> arg1(arg1_, this);
   data_root<object> arg2(arg2_, this);
@@ -74,8 +67,8 @@ void factor_vm::general_error(vm_error_type error, cell arg1_, cell arg2_) {
                       arg1.value(), arg2.value());
     ctx->push(error_object);
 
-    /* Clear the data roots again since arg1 and arg2's destructors
-       won't be called. */
+    /* Clear the data roots since arg1 and arg2's destructors won't be
+       called. */
     data_roots.clear();
 
     /* The unwind-native-frames subprimitive will clear faulting_p