vm: report callstack overflow
parent
11ddbc03a4
commit
b5f7e91bdc
|
@ -120,6 +120,8 @@ HOOK: signal-error. os ( obj -- )
|
|||
: datastack-overflow. ( obj -- ) "Data" stack-overflow. ;
|
||||
: retainstack-underflow. ( obj -- ) "Retain" stack-underflow. ;
|
||||
: retainstack-overflow. ( obj -- ) "Retain" stack-overflow. ;
|
||||
: callstack-underflow. ( obj -- ) "Call" stack-underflow. ;
|
||||
: callstack-overflow. ( obj -- ) "Call" stack-overflow. ;
|
||||
|
||||
: memory-error. ( error -- )
|
||||
"Memory protection fault at address " write third .h ;
|
||||
|
@ -153,8 +155,10 @@ PREDICATE: vm-error < array
|
|||
{ 11 [ datastack-overflow. ] }
|
||||
{ 12 [ retainstack-underflow. ] }
|
||||
{ 13 [ retainstack-overflow. ] }
|
||||
{ 14 [ memory-error. ] }
|
||||
{ 15 [ fp-trap-error. ] }
|
||||
{ 13 [ callstack-underflow. ] }
|
||||
{ 14 [ callstack-overflow. ] }
|
||||
{ 15 [ memory-error. ] }
|
||||
{ 16 [ fp-trap-error. ] }
|
||||
} ; inline
|
||||
|
||||
M: vm-error summary drop "VM error" ;
|
||||
|
|
|
@ -46,6 +46,10 @@ IN: kernel.tests
|
|||
|
||||
[ ] [ :c ] unit-test
|
||||
|
||||
: overflow-c ( -- ) overflow-c overflow-c ;
|
||||
|
||||
[ overflow-c ] [ { "kernel-error" 14 f f } = ] must-fail-with
|
||||
|
||||
[ -7 <byte-array> ] must-fail
|
||||
|
||||
[ 3 ] [ t 3 and ] unit-test
|
||||
|
|
|
@ -87,6 +87,8 @@ void factor_vm::not_implemented_error()
|
|||
|
||||
void factor_vm::memory_protection_error(cell addr, stack_frame *stack)
|
||||
{
|
||||
/* Retain and call stack underflows are not supposed to happen */
|
||||
|
||||
if(ctx->datastack_seg->underflow_p(addr))
|
||||
general_error(ERROR_DATASTACK_UNDERFLOW,false_object,false_object,stack);
|
||||
else if(ctx->datastack_seg->overflow_p(addr))
|
||||
|
@ -95,6 +97,10 @@ void factor_vm::memory_protection_error(cell addr, stack_frame *stack)
|
|||
general_error(ERROR_RETAINSTACK_UNDERFLOW,false_object,false_object,stack);
|
||||
else if(ctx->retainstack_seg->overflow_p(addr))
|
||||
general_error(ERROR_RETAINSTACK_OVERFLOW,false_object,false_object,stack);
|
||||
else if(ctx->callstack_seg->underflow_p(addr))
|
||||
general_error(ERROR_CALLSTACK_UNDERFLOW,false_object,false_object,stack);
|
||||
else if(ctx->callstack_seg->overflow_p(addr))
|
||||
general_error(ERROR_CALLSTACK_OVERFLOW,false_object,false_object,stack);
|
||||
else
|
||||
general_error(ERROR_MEMORY,allot_cell(addr),false_object,stack);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ enum vm_error_type
|
|||
ERROR_DATASTACK_OVERFLOW,
|
||||
ERROR_RETAINSTACK_UNDERFLOW,
|
||||
ERROR_RETAINSTACK_OVERFLOW,
|
||||
ERROR_CALLSTACK_UNDERFLOW,
|
||||
ERROR_CALLSTACK_OVERFLOW,
|
||||
ERROR_MEMORY,
|
||||
ERROR_FP_TRAP,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue