VM: try and recover with a kernel error from the callback heap running out

db4
Björn Lindqvist 2014-09-09 12:44:01 +02:00 committed by John Benediktsson
parent 1824680ad1
commit 4867e7bc96
4 changed files with 36 additions and 23 deletions

View File

@ -148,6 +148,9 @@ HOOK: signal-error. os ( obj -- )
: interrupt-error. ( error -- )
"Interrupt" print drop ;
: callback-space-overflow. ( error -- )
"Callback space overflow" print drop ;
PREDICATE: vm-error < array
dup length 2 < [ drop f ] [
{
@ -178,6 +181,7 @@ PREDICATE: vm-error < array
[ memory-error. ]
[ fp-trap-error. ]
[ interrupt-error. ]
[ callback-space-overflow. ]
} ; inline
M: vm-error summary drop "VM error" ;

View File

@ -352,6 +352,8 @@ CONSTANT: OBJ-WAITING-CALLBACKS 73
CONSTANT: OBJ-SIGNAL-PIPE 74
CONSTANT: OBJ-INSTALL-PREFIX 75
! Context object count and identifiers must be kept in sync with:
! vm/contexts.hpp
@ -363,9 +365,10 @@ CONSTANT: CONTEXT-OBJ-CONTEXT 2
CONSTANT: CONTEXT-OBJ-IN-CALLBACK-P 3
! Runtime errors must be kept in sync with:
! basis/debugger/debugger.factor
! vm/errors.hpp
CONSTANT: kernel-error-count 20
CONSTANT: kernel-error-count 21
CONSTANT: ERROR-EXPIRED 0
CONSTANT: ERROR-IO 1
@ -387,5 +390,6 @@ CONSTANT: ERROR-CALLSTACK-OVERFLOW 16
CONSTANT: ERROR-MEMORY 17
CONSTANT: ERROR-FP-TRAP 18
CONSTANT: ERROR-INTERRUPT 19
CONSTANT: ERROR-CALLBACK-SPACE-OVERFLOW 20
PRIVATE>

View File

@ -61,8 +61,12 @@ code_block* callback_heap::add(cell owner, cell return_rewind) {
cell size = array_capacity(insns.untagged());
cell bump = align(size + sizeof(code_block), data_alignment);
if (here + bump > seg->end)
fatal_error("Out of callback space", 0);
if (here + bump > seg->end) {
parent->general_error(ERROR_CALLBACK_SPACE_OVERFLOW,
false_object,
false_object);
}
free_heap_block* free_block = (free_heap_block*)here;
free_block->make_free(bump);

View File

@ -24,6 +24,7 @@ enum vm_error_type {
ERROR_MEMORY,
ERROR_FP_TRAP,
ERROR_INTERRUPT,
ERROR_CALLBACK_SPACE_OVERFLOW
};
void fatal_error(const char* msg, cell tagged);