{"record":{"id":"d03133b1df3fef49","repo":"windmill-labs/windmill","slug":"clock-is-not-supported-d03133","errorCode":null,"errorMessage":"clock is not supported","messagePattern":"clock is not supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-java/src/wasm_libc.rs","lineNumber":136,"sourceCode":"}\n\n/* -------------------------------- wctype.h -------------------------------- */\n\n#[no_mangle]\npub unsafe extern \"C\" fn iswspace(c: c_int) -> bool {\n    char::from_u32(c as u32).map_or(false, |c| c.is_whitespace())\n}\n\n#[no_mangle]\npub unsafe extern \"C\" fn iswalnum(c: c_int) -> bool {\n    char::from_u32(c as u32).map_or(false, |c| c.is_alphanumeric())\n}\n\n/* --------------------------------- time.h --------------------------------- */\n\n#[no_mangle]\npub unsafe extern \"C\" fn clock() -> u64 {\n    panic!(\"clock is not supported\");\n}\n\n/* --------------------------------- ctype.h -------------------------------- */\n\n#[no_mangle]\npub unsafe extern \"C\" fn isprint(c: c_int) -> bool {\n    c >= 32 && c <= 126\n}\n\n/* --------------------------------- stdio.h -------------------------------- */\n\n#[no_mangle]\npub unsafe extern \"C\" fn fprintf(_file: *mut c_void, _format: *const c_void, _args: ...) -> c_int {\n    panic!(\"fprintf is not supported\");\n}\n\n#[no_mangle]\npub unsafe extern \"C\" fn fputs(_s: *const c_void, _file: *mut c_void) -> c_int {","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-java/src/wasm_libc.rs#L118-L154","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Locate the code path calling clock() and remove or bypass it — the parser cannot satisfy time queries.","Upgrade windmill-parser-java in case newer versions implement or avoid this symbol.","Wrap parser invocation so inputs that reach this path are rejected earlier with a meaningful error.","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."],"exampleFix":"// before: native C component in the WASM build\nclock_t start = clock();\n\n// after: guard timing behind a non-WASM build flag\n#ifndef __wasm__\nclock_t start = clock();\n#else\nclock_t start = 0; // clock() unsupported in wasm_libc shim\n#endif","handlingStrategy":"try-catch","validationCode":"// No caller-side data check can detect clock() usage; guard by excluding known timing-dependent code paths from parsed inputs.\nif (input.includes('clock(')) log.warn('input references clock(); parser WASM does not support it');","typeGuard":null,"tryCatchPattern":"try {\n  const result = parse(input);\n} catch (e) {\n  if (String(e).includes('clock is not supported')) {\n    throw new Error('parsed code uses clock(), unsupported in parser WASM sandbox');\n  }\n  throw e;\n}","preventionTips":["Avoid parsing/executing code paths that measure CPU time inside the WASM parser.","Do not assume a full libc in the sandbox; check the wasm_libc.rs stub list for supported symbols.","Report missing time APIs upstream instead of working around at call time.","Wrap parser calls centrally so unsupported-symbol panics map to clear user-facing errors."],"tags":["wasm","libc","time","panic","unsupported-symbol"],"backgroundTag":"wasm-libc-stub-panic","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}