Add CEK loop debug print every ~1M steps to diagnose hangs

Prints phase + control expression every 1,048,576 steps so infinite
loops become visible in logs. Only fires when step count is high
enough to indicate a real hang, not normal execution.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-29 20:00:15 +00:00
parent f978792e62
commit 1ad90ed23d

View File

@@ -388,7 +388,12 @@ and cek_run state =
if n land 4095 = 0 then begin
let lim = Atomic.get _step_limit in
if lim > 0 && n >= lim then
raise (Eval_error (Printf.sprintf "Render step limit exceeded (%d steps)" n))
raise (Eval_error (Printf.sprintf "Render step limit exceeded (%d steps)" n));
if n land 1048575 = 0 && n > 0 then
Printf.eprintf "[cek] %d steps, phase=%s control=%s\n%!" n
(match cek_phase !s with String p -> p | _ -> "?")
(String.sub (Sx_runtime.value_to_str (cek_control !s)) 0
(min 80 (String.length (Sx_runtime.value_to_str (cek_control !s)))))
end
done;
cek_value !s