{"record":{"id":"84ed6d0fe792bce0","repo":"windmill-labs/windmill","slug":"clock-is-not-supported","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-csharp/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-csharp/src/wasm_libc.rs#L118-L154","documentation":"The C# parser crate compiles a minimal libc shim (wasm_libc.rs) so a .NET runtime can run inside WebAssembly. clock() is deliberately stubbed: it immediately panics with \"clock is not supported\" because the browser/WASM host provides no meaningful process CPU time. Any WASM code path that imports or calls the C `clock()` function hits this panic at runtime.","triggerScenarios":"The .NET/WASM runtime executing inside the C# parser calls the libc `clock()` symbol (e.g. mono runtime diagnostics, Environment.TickCount/processor-time probing, or a GC/profiling path requesting CPU time).","commonSituations":"Running code in the browser-based C# parser that measures CPU time; a .NET runtime build or BCL version that newly imports clock(); using profiling or timing libraries that call clock(2) under the hood.","solutions":["Find which code inside the WASM runtime calls clock() and remove or replace it with a supported timing API (e.g. clock_gettime/gettimeofday if implemented).","Guard the call so it is only made on native hosts, not in the WASM parser environment.","If you control wasm_libc.rs, implement clock() to return a best-effort value (e.g. 0 or a monotonic counter) instead of panicking.","Report/upgrade to a .NET WASM runtime build whose bootstrap avoids clock()."],"exampleFix":"// before\nlet t = clock(); // panics in wasm\n// after\nlet t = std::time::Instant::now(); // or a host-provided monotonic clock","handlingStrategy":"validation","validationCode":"// Before running code in the WASM C# parser, avoid host-unsupported libc calls:\nif (OperatingSystem.IsBrowser() || isWasmHost)\n{\n    // never call CPU-time APIs like clock(); use managed time instead\n    var elapsed = Stopwatch.GetTimestamp(); // System.Diagnostics.Stopwatch\n}","typeGuard":"function avoidsCpuClockCode(source) {\n  return !/\\bclock\\s*\\(/.test(source); // true => safe to run in the wasm host\n}","tryCatchPattern":"try {\n  runInWasmParser(code);\n} catch (e) {\n  if (String(e?.message ?? e).includes(\"clock is not supported\")) {\n    console.warn(\"CPU-time APIs are unavailable in the wasm C# parser; use managed timing.\");\n  } else {\n    throw e;\n  }\n}","preventionTips":["Avoid native/profiling dependencies that call clock() when targeting the WASM parser.","Use managed timing APIs (Stopwatch, DateTime.UtcNow) instead of libc time functions.","Keep a list of unsupported libc symbols for the host and lint native code against them.","If you maintain the shim, prefer returning a benign value over panicking for diagnostic clocks."],"tags":["wasm","libc","csharp","unsupported-symbol"],"backgroundTag":"unsupported-wasm-libc-symbol","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}