{"record":{"id":"5e20ab955c9686af","repo":"windmill-labs/windmill","slug":"fputc-is-not-supported-5e20ab","errorCode":null,"errorMessage":"fputc is not supported","messagePattern":"fputc is not supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-r/src/wasm_libc.rs","lineNumber":246,"sourceCode":"pub 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 {\n    panic!(\"fputs is not supported\");\n}\n\n#[no_mangle]\npub unsafe extern \"C\" fn fputc(_c: c_int, _file: *mut c_void) -> c_int {\n    panic!(\"fputc is not supported\");\n}\n\n#[no_mangle]\npub unsafe extern \"C\" fn fdopen(_fd: c_int, _mode: *const c_void) -> *mut c_void {\n    panic!(\"fdopen is not supported\");\n}\n\n#[no_mangle]\npub unsafe extern \"C\" fn fclose(_file: *mut c_void) -> c_int {\n    panic!(\"fclose is not supported\");\n}\n\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,","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-r/src/wasm_libc.rs#L228-L264","documentation":"`fputc` (write a single character to a FILE*) is one of the intentionally unimplemented libc shims in the R parser's WASM runtime: the stub exists only to satisfy linking and panics when entered. Hitting it means executing code that performs character-level stream output the sandbox does not support.","triggerScenarios":"Calling the exported `fputc` shim at backend/parsers/windmill-parser-r/src/wasm_libc.rs:246, reached when embedded/compiled code writes characters to stdout/stderr or a file stream.","commonSituations":"C code compiled into the WASM uses putc/fputc for output loops; a dependency formats output char-by-char; the R parser is run with code that prints incrementally instead of returning a value.","solutions":["Replace the calling code's char-by-char output with a supported mechanism (buffer the string and use a supported path)","Implement the fputc shim to accumulate/forward output to the host instead of panicking","Avoid linking the library or code path that depends on stdio character output","Track as a known unsupported libc symbol if the code cannot be changed"],"exampleFix":"// before (stub)\n#[no_mangle]\npub unsafe extern \"C\" fn fputc(_c: c_int, _file: *mut c_void) -> c_int {\n    panic!(\"fputc is not supported\");\n}\n// after (forward to host)\n#[no_mangle]\npub unsafe extern \"C\" fn fputc(c: c_int, _file: *mut c_void) -> c_int {\n    print!(\"{}\", c as u8 as char);\n    c\n}","handlingStrategy":"try-catch","validationCode":"// Reject R/C sources that emit char-by-char via putc/fputc before execution\nif (/\\b(fputc|putc)\\s*\\(/.test(rSource)) {\n  throw new Error(\"char-level stdio output (fputc) is unsupported in the R parser WASM\");\n}","typeGuard":"fn is_unsupported_stdio_symbol(sym: &str) -> bool {\n    matches!(sym, \"fputc\" | \"putc\" | \"fputs\" | \"fwrite\" | \"fclose\" | \"fdopen\")\n}","tryCatchPattern":"let outcome = std::panic::catch_unwind(AssertUnwindSafe(|| run_wasm_r(payload)));\nif let Err(panic) = outcome {\n    let msg = panic_msg(&panic);\n    if msg.contains(\"fputc is not supported\") {\n        // buffer the output path instead: rewrite source to build a string and return it\n    } else { std::panic::resume_unwind(panic); }\n}","preventionTips":["Build output as complete strings/values instead of incremental character writes","Inspect dependencies compiled into the WASM for putc/fputc usage","Catch panics at the WASM boundary and map 'not supported' panics to clear user errors","Add tests asserting scripts avoid panicking stdio stubs"],"tags":["wasm","libc","rust","r-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"}