owi
owi copied to clipboard
Add timeout/heartbeat feature
Would be great to add either a timeout option, or a "heartbeat" one (limit on the number of instructions executed, does not depend on the machine it's running on).
In case it helps, here's some wat making owi sym
run for very long. It's Ackermann with m = 4
.
Ackermann.wat
(module
(import "symbolic" "i32_symbol" (func $gen_i32 (result i32)))
(func $ack (param i32 i32) (result i32)
block ;; label = @1
local.get 0
i32.eqz
br_if 0 (;@1;)
loop ;; label = @2
block ;; label = @3
block ;; label = @4
local.get 1
br_if 0 (;@4;)
i32.const 1
local.set 1
br 1 (;@3;)
end
local.get 0
local.get 1
i32.const -1
i32.add
call $ack
local.set 1
end
local.get 0
i32.const -1
i32.add
local.tee 0
br_if 0 (;@2;)
end
end
local.get 1
i32.const 1
i32.add)
(func $start
(local $result i32)
i32.const 4
call $gen_i32
call $ack
local.set $result
(if
(i32.lt_s (i32.const 72) (local.get $result))
(then unreachable)
)
)
(start $start)
)
I believe having both makes sense. We should add them to owi c
, owi sym
and owi run
(I'm less sure about owi script
). @epatrizio, is this something you would like to try implementing ? We already have a timeout mechanism for the fuzzer so it shouldn't be too hard to implement.
The hearbeat one may be a little bit more tricky due to parallel execution in the symbolic case.
(also cc @Swrup who may be interested in implementing this :-))