errors.cpp: general_error() throws away its args when it calls compact_gc() when compiled with DEBUG=1. Save the args as data_roots instead. Fixes #615. See #620.

db4
Doug Coleman 2012-08-15 16:36:36 -07:00
parent 8d6002c765
commit beb202b3de
1 changed files with 7 additions and 4 deletions

View File

@ -41,7 +41,7 @@ void out_of_memory()
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;
@ -50,6 +50,9 @@ void factor_vm::general_error(vm_error_type error, cell arg1, cell arg2)
bignum_roots.clear();
code_roots.clear();
data_root<object> arg1(arg1_,this);
data_root<object> arg2(arg2_,this);
/* If we had an underflow or overflow, data or retain stack
pointers might be out of bounds, so fix them before allocating
anything */
@ -69,7 +72,7 @@ void factor_vm::general_error(vm_error_type error, cell arg1, cell arg2)
/* Now its safe to allocate and GC */
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);
@ -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 << "error: " << error << std::endl;
std::cout << "arg 1: "; print_obj(arg1); std::cout << std::endl;
std::cout << "arg 2: "; print_obj(arg2); std::cout << std::endl;
std::cout << "arg 1: "; print_obj(arg1.value()); std::cout << std::endl;
std::cout << "arg 2: "; print_obj(arg2.value()); std::cout << std::endl;
factorbug();
abort();
}