{"record":{"id":"a4508e2e9d21c6b1","repo":"windmill-labs/windmill","slug":"vsnprintf-is-not-supported-a4508e","errorCode":null,"errorMessage":"vsnprintf is not supported","messagePattern":"vsnprintf is not supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-r/src/wasm_libc.rs","lineNumber":276,"sourceCode":"\n#[no_mangle]\npub unsafe extern \"C\" fn fwrite(\n    _ptr: *const c_void,\n    _size: usize,\n    _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":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-r/src/wasm_libc.rs#L258-L294","documentation":"This error comes from a hand-written libc shim in Windmill's R parser WASM crate (backend/parsers/windmill-parser-r/src/wasm_libc.rs). The R parser is compiled C/R code running inside a WASM runtime, and this file exports the libc symbols the compiled code links against. vsnprintf is intentionally left unimplemented, so if the WASM code ever calls it the stub panics with 'vsnprintf is not supported'. It exists so the module links, not to provide functionality.","triggerScenarios":"The compiled R parser WASM executes a code path that calls the C library's vsnprintf (formatted output into a sized buffer, e.g. via sprintf-family internals or a formatting-heavy code path in the parser runtime).","commonSituations":"Parsing R code that makes the underlying C runtime reach a formatted-print path not exercised by the shim authors; running a parser/WASM version where a previously unused symbol becomes linked in; sandboxed/browser runtimes where real libc stdio is unavailable.","solutions":["Identify why the parsed R input drives vsnprintf (often a sprintf/format call in the parsed script's syntax path) and simplify or restructure the input","Upgrade windmill-parser-r (or the vendored parser runtime) to a version that implements vsnprintf in wasm_libc.rs","Locally patch wasm_libc.rs:276 to implement vsnprintf (or route it to the console_log helper) and rebuild the WASM parser","If the panic comes from an unexpected code path, capture the WASM backtrace and report the triggering R snippet upstream"],"exampleFix":"// before (wasm_libc.rs)\npub unsafe extern \"C\" fn vsnprintf(_buf: *mut c_char, _size: usize, _format: *const c_char, _args: ...) -> c_int {\n    panic!(\"vsnprintf is not supported\");\n}\n// after: implement or delegate, e.g. minimum viable stub\npub unsafe extern \"C\" fn vsnprintf(_buf: *mut c_char, _size: usize, _format: *const c_char, _args: ...) -> c_int {\n    0 // return 0 (no bytes written) instead of panicking\n}","handlingStrategy":"try-catch","validationCode":"// JS side, before invoking the WASM R parser:\nfunction inputLikelySafe(rSource) {\n  return typeof rSource === 'string' && rSource.length < 1_000_000 && !/sprintf|formatC/.test(rSource);\n}\nif (!inputLikelySafe(rSource)) throw new Error('Input may hit unsupported WASM libc paths');","typeGuard":"function isPanicError(e) {\n  return e instanceof Error && /is not supported/.test(e.message);\n}","tryCatchPattern":"try {\n  const ast = rParser.parse(rSource);\n} catch (e) {\n  if (isPanicError(e)) {\n    console.warn('R parser hit unsupported libc call; falling back');\n    return fallbackParse(rSource); // e.g. regex-based or remote parse\n  }\n  throw e;\n}","preventionTips":["Keep the windmill-parser-r WASM build current so newly linked libc symbols get stubbed or implemented","Avoid R inputs that drive formatting code paths (sprintf/formatC) through the parser","Wrap every parser.parse call in error handling — any unimplemented libc call aborts parsing entirely","Log the WASM backtrace on panic to identify the missing symbol and patch wasm_libc.rs accordingly"],"tags":["wasm","rust","libc","parser"],"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"}