{"record":{"id":"c7b93c0bb9dbf757","repo":"windmill-labs/windmill","slug":"snprintf-is-not-supported-c7b93c","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-r/src/wasm_libc.rs","lineNumber":287,"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!(\"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":269,"sourceCodeEnd":294,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-r/src/wasm_libc.rs#L269-L294","documentation":"Stub in the R parser WASM libc shim (wasm_libc.rs:287). snprintf takes no real arguments here and always panics, meaning formatted string building in C is unsupported inside this WASM parser. The symbol is exported only so the compiled parser links successfully.","triggerScenarios":"The compiled R parser runtime calls C snprintf (bounded formatted output), e.g. when constructing messages or names during parsing.","commonSituations":"Parser versions whose code paths format strings in C; parsing inputs that steer the runtime into message-building branches; missing host stdio bindings in the WASM environment.","solutions":["Implement snprintf in wasm_libc.rs (format via Rust and copy into the buffer) and rebuild the parser WASM","Upgrade windmill-parser-r to a build that supports or avoids snprintf","Change the R input so the parser never reaches the snprintf call site","File the triggering snippet upstream with a backtrace to get the symbol implemented"],"exampleFix":"// before\npub extern \"C\" fn snprintf() {\n    panic!(\"snprintf is not supported\");\n}\n// after: bounded no-op that reports truncation instead of aborting\npub unsafe extern \"C\" fn snprintf(buf: *mut c_char, _bufsz: usize, _format: *const c_char) -> c_int {\n    if !buf.is_null() { *buf = 0 as c_char; }\n    0\n}","handlingStrategy":"try-catch","validationCode":"// Smoke-test the parser with a representative input before batch use:\nawait rParser.parse(sampleRSource); // if this panics with snprintf, skip batch parsing","typeGuard":"function isSnprintfPanic(e) {\n  return e instanceof Error && e.message.includes('snprintf is not supported');\n}","tryCatchPattern":"try {\n  const ast = rParser.parse(rSource);\n} catch (e) {\n  if (isSnprintfPanic(e)) {\n    return { ok: false, reason: 'unsupported-formatting-path' };\n  }\n  throw e;\n}","preventionTips":["Implement snprintf in the shim (format in Rust, copy into buffer) when upgrading the parser","Pre-screen R inputs for constructs that reach formatted-message code paths","Always parse inside a try/catch; the panic kills the whole parse, not one node","Track parser WASM builds: re-run your corpus smoke test after every upgrade"],"tags":["wasm","rust","libc","stdio"],"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"}