{"record":{"id":"d88156047daaf60f","repo":"windmill-labs/windmill","slug":"snprintf-is-not-supported","errorCode":null,"errorMessage":"snprintf is not supported","messagePattern":"snprintf is not supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-csharp/src/wasm_libc.rs","lineNumber":201,"sourceCode":"#[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!(\"asdasd\");\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":183,"sourceCodeEnd":208,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-csharp/src/wasm_libc.rs#L183-L208","documentation":"snprintf() is stubbed in wasm_libc.rs as a zero-argument function that panics with \"snprintf is not supported\". Because the stub takes no parameters, ANY snprintf call signature links to it and then aborts at runtime. Formatted string building through snprintf is therefore unsupported in the WASM host.","triggerScenarios":"Any WASM-runtime code path calling snprintf(buffer, bufsz, format, ...) — usually error-message construction or string formatting in native/C-glue code.","commonSituations":"String building in vendored C deps; assert/diagnostic message formatting; a runtime or library upgrade that newly imports snprintf.","solutions":["Remove or bypass the code path calling snprintf in the WASM build.","Implement a real snprintf in wasm_libc.rs (write at most size-1 bytes plus NUL, return would-be length).","Replace calls with a supported formatter (Rust format_args! or a wasm-supported vsnprintf).","Update the runtime so formatting goes through managed .NET APIs rather than libc snprintf."],"exampleFix":"// before\nsnprintf(buf, sizeof(buf), \"val=%d\", v);\n// after\nlet s = format!(\"val={}\", v); // then copy into buf","handlingStrategy":"validation","validationCode":"// Detect snprintf usage in code/dependencies bound for the wasm C# parser:\nif (isWasmHost && /\\bsnprintf\\s*\\(/.test(nativeSource)) {\n  throw new Error(\"snprintf is not linked to a working shim in the wasm parser host.\");\n}","typeGuard":"function usesSnprintf(source) {\n  return /\\bsnprintf\\s*\\(/.test(source); // true => will panic in the wasm host\n}","tryCatchPattern":"try {\n  runInWasmParser(code);\n} catch (e) {\n  if (String(e?.message ?? e).includes(\"snprintf is not supported\")) {\n    console.warn(\"snprintf is unsupported in wasm; use managed formatting.\");\n  } else {\n    throw e;\n  }\n}","preventionTips":["Never rely on libc snprintf in wasm-targeted native code.","Implement a real snprintf shim (bounded write + NUL, return length) if callers need it.","Prefer .NET string interpolation over C formatting in the wasm runtime.","Re-test dependencies after runtime upgrades, since import sets can change."],"tags":["wasm","libc","csharp","printf","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"}