home/ atoms/ chuck-silent-failure-no-time-advance

A ChucK while-loop without a time-advance silently hangs the VM at 100% CPU with no audio

The single most common ChucK bug: a while or for loop body that never executes <dur> => now; causes the VM to spin infinitely. No error message appears, no audio plays, and the CPU pegs at 100%. ChucK’s strongly-timed model requires explicit time advancement — the loop is semantically asking ‘what happens in zero time?’, and the answer is an infinite loop of zero-duration steps. Fix: add a time advance inside every loop body (e.g. 100::ms => now;). To hold a voice open indefinitely, use while(true) 1::second => now;.

Examples

while(true) { SinOsc s => dac; } — no time advance, VM hangs silently. Fixed: while(true) { 0.5 => s.freq; 100::ms => now; }.

Assessment

Explain why a ChucK loop without <dur> => now hangs silently rather than throwing an error, and write the correct minimum pattern to hold an audio voice open.

“No time advance → infinite silent loop** | a `while`/`for` body with **no `<dur> => now;`** | **No error**; VM appears to hang, 100% CPU, silence”
context/ · L5-debug/chuck.md · chunk 1