{"record":{"id":"d12d29dacb637eb7","repo":"windmill-labs/windmill","slug":"fwrite-is-not-supported","errorCode":null,"errorMessage":"fwrite is not supported","messagePattern":"fwrite is not supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-csharp/src/wasm_libc.rs","lineNumber":180,"sourceCode":"\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,\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!(\"asdasd\");\n}\n\n// int snprintf( char* restrict buffer, size_t bufsz, const char* restrict format, ... );","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-csharp/src/wasm_libc.rs#L162-L198","documentation":"fwrite() is a panic stub in wasm_libc.rs (\"fwrite is not supported\"). Writing raw blocks to a FILE* is unsupported because no real streams exist in the WASM host. Any call — including printf-family internals routed through fwrite — aborts execution.","triggerScenarios":"The runtime or native code calls fwrite(ptr, size, nmemb, stream) to write bytes to stdout/stderr or a file; printf-family implementations that flush via fwrite.","commonSituations":"puts/printf implemented on top of fwrite in a vendored libc; binary dumps to streams; mono diagnostic paths writing buffers to stderr.","solutions":["Disable the runtime feature that performs stream writes in WASM.","Route buffered output to the console_log shim or an in-memory ring buffer instead.","Implement fwrite in wasm_libc.rs forwarding to a supported sink (write length-checked bytes to console).","Rebuild the native component with stdio removed."],"exampleFix":"// before\nfwrite(buf, 1, len, stdout);\n// after\nconsole_log!(\"{}\", core::str::from_utf8(&buf[..len]).unwrap_or(\"<binary>\"));","handlingStrategy":"try-catch","validationCode":"// Intercept raw stream writes before executing in the wasm host:\nif (isWasmHost && writesToStreams(code)) {\n  throw new Error(\"fwrite-style stream output unsupported in the wasm C# parser.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  runInWasmParser(code);\n} catch (e) {\n  if (String(e?.message ?? e).includes(\"fwrite is not supported\")) {\n    console.warn(\"fwrite is unsupported in wasm; buffer output or route it to the console shim.\");\n  } else {\n    throw e;\n  }\n}","preventionTips":["Avoid native deps that write binary blocks to streams under wasm.","Implement fwrite in the shim to forward to a supported sink if needed.","Suppress printf-family output in wasm runtime configuration.","Add a smoke test that exercises output paths in the wasm parser."],"tags":["wasm","libc","csharp","stdio","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"}