{"record":{"id":"325aad154d044666","repo":"windmill-labs/windmill","slug":"clock-gettime-is-not-supported-325aad","errorCode":null,"errorMessage":"clock_gettime is not supported","messagePattern":"clock_gettime is not supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-r/src/wasm_libc.rs","lineNumber":281,"sourceCode":"    _nmemb: usize,\n    _stream: *mut c_void,\n) -> usize {\n    panic!(\"fwrite is not supported\");\n}\n\n#[no_mangle]\npub unsafe extern \"C\" fn vsnprintf(\n    _buf: *mut c_char,\n    _size: usize,\n    _format: *const c_char,\n    _args: ...\n) -> c_int {\n    panic!(\"vsnprintf is not supported\");\n}\n\n#[no_mangle]\npub extern \"C\" fn clock_gettime(ptr: usize, new_size: usize) {\n    panic!(\"clock_gettime is not supported\");\n}\n\n// int snprintf( char* restrict buffer, size_t bufsz, const char* restrict format, ... );\n#[no_mangle]\npub extern \"C\" fn snprintf() {\n    panic!(\"snprintf is not supported\");\n}\n\n#[no_mangle]\npub extern \"C\" fn __assert_fail(_: *const i32, _: *const i32, _: *const i32, _: *const i32) {\n    panic!(\"oh no\");\n}\n","sourceCodeStart":263,"sourceCodeEnd":294,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-r/src/wasm_libc.rs#L263-L294","documentation":"Stub in Windmill's R parser WASM crate (wasm_libc.rs:281). clock_gettime is not implemented in the WASM libc shim, so any call from the compiled parser panics with 'clock_gettime is not supported'. The shim only exists to satisfy the linker; time functions have no meaning in the sandboxed WASM runtime and were deliberately omitted.","triggerScenarios":"The R parser WASM executes code that queries the monotonic/realtime clock via C's clock_gettime (CLOCK_MONOTONIC/CLOCK_REALTIME), typically from a benchmarking, timing, or RNG-seeding path in the embedded runtime.","commonSituations":"Parsing R scripts whose runtime initializes something time-based; running an older/newer parser build that newly pulls in time-dependent C code; WASM/browser environments without host time syscalls wired up.","solutions":["Upgrade the windmill-parser-r crate/shim so clock_gettime is implemented (e.g. return a fixed value) instead of panicking","Patch wasm_libc.rs to provide a trivial clock_gettime implementation (write zeroed timespec) and rebuild the WASM module","Check which R input triggers the timing path and avoid that construct if the parser version cannot be changed","Report the panic with the WASM backtrace so the shim can gain the missing symbol"],"exampleFix":"// before\npub extern \"C\" fn clock_gettime(ptr: usize, new_size: usize) {\n    panic!(\"clock_gettime is not supported\");\n}\n// after\npub unsafe extern \"C\" fn clock_gettime(clk_id: c_int, tp: *mut timespec) {\n    if !tp.is_null() { (*tp).tv_sec = 0; (*tp).tv_nsec = 0; }\n}","handlingStrategy":"try-catch","validationCode":"// Pre-check the runtime can parse without time syscalls:\ntry { rParser.parse('x <- 1'); } catch (e) { throw new Error('R parser runtime unusable: ' + e.message); }","typeGuard":"function isClockPanic(e) {\n  return e instanceof Error && e.message.includes('clock_gettime is not supported');\n}","tryCatchPattern":"try {\n  const ast = rParser.parse(rSource);\n} catch (e) {\n  if (isClockPanic(e)) return null; // treat as parse-unavailable, do not retry\n  throw e;\n}","preventionTips":["Rebuild the parser WASM with a benign clock_gettime stub if the runtime links time-based code","Do not retry parsing on this error — it is deterministic for the same build/input","Pin a parser version known to parse your R corpus without hitting the time path","Capture backtraces to confirm which guest code calls clock_gettime"],"tags":["wasm","rust","libc","time"],"backgroundTag":"wasm-libc-function-not-supported","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"}