windmill-labs/windmill · error
fprintf is not supported
Error message
fprintf is not supported
What it means
The windmill-parser-r WASM libc shim stubs fprintf (stdio.h) with a panic, because the WASM sandbox has no file descriptors or output streams for the compiled C parser to write to. Any code path that tries to print (error messages, debug logging, scanner diagnostics via fprintf(stderr, ...)) hits this stub and panics with "fprintf is not supported".
Source
Thrown at backend/parsers/windmill-parser-r/src/wasm_libc.rs:236
/* --------------------------------- time.h --------------------------------- */
#[no_mangle]
pub unsafe extern "C" fn clock() -> u64 {
panic!("clock is not supported");
}
/* --------------------------------- ctype.h -------------------------------- */
#[no_mangle]
pub unsafe extern "C" fn isprint(c: c_int) -> bool {
c >= 32 && c <= 126
}
/* --------------------------------- stdio.h -------------------------------- */
#[no_mangle]
pub unsafe extern "C" fn fprintf(_file: *mut c_void, _format: *const c_void, _args: ...) -> c_int {
panic!("fprintf is not supported");
}
#[no_mangle]
pub unsafe extern "C" fn fputs(_s: *const c_void, _file: *mut c_void) -> c_int {
panic!("fputs is not supported");
}
#[no_mangle]
pub unsafe extern "C" fn fputc(_c: c_int, _file: *mut c_void) -> c_int {
panic!("fputc is not supported");
}
#[no_mangle]
pub unsafe extern "C" fn fdopen(_fd: c_int, _mode: *const c_void) -> *mut c_void {
panic!("fdopen is not supported");
}
#[no_mangle]View on GitHub (pinned to e474e8803c)
Solutions
- Trace which call site invokes fprintf (instrument the shim to log the format string and then panic) and fix the input/state that reaches that error branch.
- Reimplement fprintf in the shim to format and route output to console.log via the existing console_log! macro instead of panicking, so error paths degrade to log output.
- Rebuild the grammar without debug instrumentation (disable debug flags) so fprintf is compiled out.
- Patch the grammar's scanner.c to remove or gate fprintf usage for WASM builds.
Example fix
// before (wasm_libc.rs)
#[no_mangle]
pub unsafe extern "C" fn fprintf(_file: *mut c_void, _format: *const c_void, _args: ...) -> c_int {
panic!("fprintf is not supported");
}
// after — route output to the console instead of panicking
#[no_mangle]
pub unsafe extern "C" fn fprintf(_file: *mut c_void, _format: *const c_void, _args: ...) -> c_int {
let msg = cstr(_format); // read the NUL-terminated format string
console_log!("fprintf: {}", msg);
msg.len() as c_int
} Defensive patterns
Strategy: try-catch
Validate before calling
// At build time, confirm the compiled parser does not call fprintf:
// grep -n 'fprintf' scanner.c src/parser.c # should be absent or WASM-gated
// At runtime, validate input before parsing to avoid error branches:
function validateDoc(src) {
return typeof src === 'string' && src.length > 0 && !src.includes('\u0000');
} Type guard
function isCleanStringDoc(src) {
return typeof src === 'string' && src.length > 0 && !src.includes('\u0000');
} Try / catch
try {
if (!validateDoc(doc)) throw new TypeError('invalid parser input');
return parser.parse(doc);
} catch (e) {
if (String(e).includes('fprintf is not supported')) {
// scanner hit an error/log branch using stdio: recreate parser,
// inspect the document, and route it to a manual-review queue
parser = new Parser();
return null;
}
throw e;
} Prevention
- Rebuild grammars without debug logging so fprintf is compiled out of WASM artifacts.
- Add a CI check that the generated C contains no fprintf references for WASM builds.
- Reimplement stdio stubs to log to console instead of panicking, so error paths degrade gracefully.
- Isolate each parse in a fresh parser instance; a panicking stub can leave shared state corrupted for later parses.
When it happens
Trigger: The compiled tree-sitter C runtime or custom scanner calls fprintf — typically fprintf(stderr, ...) in an error/debug path: logging an unexpected token, a scanner error branch, or debug instrumentation left compiled in.
Common situations: Parsing R input that reaches a scanner error branch containing fprintf(stderr, ...); a grammar built with debug logging enabled; a grammar upgrade whose error handling now prints; reusing a native-targeted scanner that assumes stderr exists.
Related errors
- snprintf is not supported
- clock is not supported
- fprintf is not supported
- fputs is not supported
- fputc is not supported
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/25192f6e93a14775.
Report an issue: GitHub.