VM: moves the code that clears the roots to the same function that

corrupts the stack
db4
Björn Lindqvist 2014-07-23 11:07:49 +02:00 committed by John Benediktsson
parent 5fd3230b2e
commit 48bf3a9ab4
2 changed files with 10 additions and 9 deletions

View 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();
}
}

View 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