HS tests: SIGALRM + raise timeout for native OCaml loops
The infinite loops in the HS parser are in transpiled native OCaml code, not in the VM or CEK step loop. Neither step counters (in cek_step_loop, cek_step, trampoline) nor VM instruction checks caught them because the loops are in direct OCaml recursion. Fix: SIGALRM handler raises Eval_error to break out of native loops. Also sets step_limit flag to catch VM loops. Combined approach handles both native OCaml recursion (alarm+raise) and VM bytecode (step check). The alarm+raise can become unreliable after ~13 timeouts in a single process, but handles the common case well. Reverts the fork-based approach which lost inter-test state. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -448,6 +448,9 @@ and run vm =
|
||||
let op = bc.(frame.ip) in
|
||||
frame.ip <- frame.ip + 1;
|
||||
incr _vm_insn_count;
|
||||
(* Check timeout flag set by SIGALRM *)
|
||||
if !_vm_insn_count land 0xFFFF = 0 && !Sx_ref.step_limit > 0 then
|
||||
raise (Eval_error "TIMEOUT: step limit exceeded");
|
||||
(try match op with
|
||||
(* ---- Constants ---- *)
|
||||
| 1 (* OP_CONST *) ->
|
||||
|
||||
Reference in New Issue
Block a user