#doc "Clears and frees every page, except for first page."
clear :: (arena: &Arena) {
walker := arena.first_arena.next;
+
while walker != null {
next := walker.next;
raw_free(arena.backing_allocator, walker);
walker = next;
}
+ arena.first_arena.next = null;
arena.size = sizeof rawptr;
}
#if Enable_Stack_Trace {
trace := runtime.info.get_stack_trace();
for trace {
- log(.Error, "Core", core.tprintf("in {} ({}:{})", it.info.func_name, it.info.file, it.current.line));
+ log(.Error, "Core", core.tprintf("in {} ({}:{})", it.info.func_name, it.info.file, it.current_line));
}
}
}
trace();
return;
}
+
+ } else {
+ //
+ // If not in debug mode, still catch the wierd cases and prevent them from breaking
+ // the free list, as this will certainly cause terrible bugs that take hours to fix.
+ //
+
+ if cast(uintptr) hb_ptr < cast(uintptr) __heap_start {
+ return;
+ }
+
+ if hb_ptr.size & Allocated_Flag != Allocated_Flag {
+ return;
+ }
+
+ if hb_ptr.magic_number != Alloc_Block_Magic_Number {
+ return;
+ }
}
hb_ptr.size &= ~Allocated_Flag;
OVMI_INSTR_EXEC(idx_arr) {
ovm_static_integer_array_t data_elem = state->program->static_data[instr->a];
- ovm_assert(VAL(instr->b).u32 < (u32) data_elem.len);
+ if (VAL(instr->b).u32 >= (u32) data_elem.len) {
+ OVMI_EXCEPTION_HOOK;
+ }
VAL(instr->r).i32 = state->program->static_integers[data_elem.start_idx + VAL(instr->b).u32];
VAL(instr->r).type = OVM_TYPE_I32;