errors.cpp: Previous fix was correct, except we shouldn't clear the data_roots before gc'ing. Laugh out loud. Fixes #615.

db4
Doug Coleman 2012-08-15 19:47:59 -07:00
parent 7e39d7ef30
commit 66de3a85dd
1 changed files with 12 additions and 9 deletions

View File

@ -41,14 +41,12 @@ void out_of_memory()
abort(); abort();
} }
void factor_vm::general_error(vm_error_type error, cell arg1, cell arg2) void factor_vm::general_error(vm_error_type error, cell arg1_, cell arg2_)
{ {
faulting_p = true; data_root<object> arg1(arg1_,this);
data_root<object> arg2(arg2_,this);
/* Reset local roots before allocating anything */ faulting_p = true;
data_roots.clear();
bignum_roots.clear();
code_roots.clear();
/* If we had an underflow or overflow, data or retain stack /* If we had an underflow or overflow, data or retain stack
pointers might be out of bounds, so fix them before allocating pointers might be out of bounds, so fix them before allocating
@ -69,10 +67,15 @@ void factor_vm::general_error(vm_error_type error, cell arg1, cell arg2)
/* Now its safe to allocate and GC */ /* Now its safe to allocate and GC */
cell error_object = allot_array_4(special_objects[OBJ_ERROR], cell error_object = allot_array_4(special_objects[OBJ_ERROR],
tag_fixnum(error),arg1,arg2); tag_fixnum(error),arg1.value(),arg2.value());
ctx->push(error_object); ctx->push(error_object);
/* Reset local roots */
data_roots.clear();
bignum_roots.clear();
code_roots.clear();
/* The unwind-native-frames subprimitive will clear faulting_p /* The unwind-native-frames subprimitive will clear faulting_p
if it was successfully reached. */ if it was successfully reached. */
unwind_native_frames(special_objects[ERROR_HANDLER_QUOT], unwind_native_frames(special_objects[ERROR_HANDLER_QUOT],
@ -84,8 +87,8 @@ void factor_vm::general_error(vm_error_type error, cell arg1, cell arg2)
{ {
std::cout << "You have triggered a bug in Factor. Please report.\n"; std::cout << "You have triggered a bug in Factor. Please report.\n";
std::cout << "error: " << error << std::endl; std::cout << "error: " << error << std::endl;
std::cout << "arg 1: "; print_obj(arg1); std::cout << std::endl; std::cout << "arg 1: "; print_obj(arg1.value()); std::cout << std::endl;
std::cout << "arg 2: "; print_obj(arg2); std::cout << std::endl; std::cout << "arg 2: "; print_obj(arg2.value()); std::cout << std::endl;
factorbug(); factorbug();
abort(); abort();
} }