windmill-labs/windmill · error

clock is not supported

Error message

clock is not supported

What it means

The `clock()` libc stub in wasm_libc.rs panics unconditionally: the WASM sandbox for the Java parser provides no time-source implementation for the C `clock()` API. The shim exists only to satisfy the linker; the library intentionally refuses to run code that reads CPU/process time.

Source

Thrown at backend/parsers/windmill-parser-java/src/wasm_libc.rs:136

}

/* -------------------------------- wctype.h -------------------------------- */

#[no_mangle]
pub unsafe extern "C" fn iswspace(c: c_int) -> bool {
    char::from_u32(c as u32).map_or(false, |c| c.is_whitespace())
}

#[no_mangle]
pub unsafe extern "C" fn iswalnum(c: c_int) -> bool {
    char::from_u32(c as u32).map_or(false, |c| c.is_alphanumeric())
}

/* --------------------------------- time.h --------------------------------- */

#[no_mangle]
pub unsafe extern "C" fn clock() -> u64 {
    panic!("clock is not supported");
}

/* --------------------------------- ctype.h -------------------------------- */

#[no_mangle]
pub unsafe extern "C" fn isprint(c: c_int) -> bool {
    c >= 32 && c <= 126
}

/* --------------------------------- stdio.h -------------------------------- */

#[no_mangle]
pub unsafe extern "C" fn fprintf(_file: *mut c_void, _format: *const c_void, _args: ...) -> c_int {
    panic!("fprintf is not supported");
}

#[no_mangle]
pub unsafe extern "C" fn fputs(_s: *const c_void, _file: *mut c_void) -> c_int {

View on GitHub (pinned to e474e8803c)

Solutions

  1. Locate the code path calling clock() and remove or bypass it — the parser cannot satisfy time queries.
  2. Upgrade windmill-parser-java in case newer versions implement or avoid this symbol.
  3. Wrap parser invocation so inputs that reach this path are rejected earlier with a meaningful error.
  4. If the call comes from code you control that is compiled into the module, replace clock() with a compile-time constant or remove timing instrumentation for WASM targets.

Example fix

// before: native C component in the WASM build
clock_t start = clock();

// after: guard timing behind a non-WASM build flag
#ifndef __wasm__
clock_t start = clock();
#else
clock_t start = 0; // clock() unsupported in wasm_libc shim
#endif
Defensive patterns

Strategy: try-catch

Validate before calling

// No caller-side data check can detect clock() usage; guard by excluding known timing-dependent code paths from parsed inputs.
if (input.includes('clock(')) log.warn('input references clock(); parser WASM does not support it');

Try / catch

try {
  const result = parse(input);
} catch (e) {
  if (String(e).includes('clock is not supported')) {
    throw new Error('parsed code uses clock(), unsupported in parser WASM sandbox');
  }
  throw e;
}

Prevention

When it happens

Trigger: Transpiled/native code inside the parser's WASM module calls C `clock()` from time.h (e.g. benchmarking code, time-based logic in a bundled native component).

Common situations: Parsing code or driving a native component that instruments elapsed CPU time; a library dependency of the parser internally measuring profiling data; ported C code assuming a full libc where only a stub set exists.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/d03133b1df3fef49. Report an issue: GitHub.