{"record":{"id":"2d373757b181b4e7","repo":"windmill-labs/windmill","slug":"fwrite-is-not-supported-2d3737","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-java/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!(\"clock_gettime is not supported\");\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-java/src/wasm_libc.rs#L162-L198","documentation":"The `fwrite` stub panics: binary block writes to a C stream are not implemented in the WASM libc shim. The symbol is exported for link compatibility only; any runtime call means the code is attempting to write data out through stdio, which the sandbox cannot do.","triggerScenarios":"Code compiled into the parser's WASM module calls `fwrite(ptr, size, nmemb, stream)` — serializing results, dumping buffers, or writing parsed output to a file/stdout.","commonSituations":"Native serializers writing output blocks; debug dump routines in bundled components; transpiled code persisting intermediate data to temp files.","solutions":["Replace the fwrite path with writes into a WASM-accessible memory buffer or a supported output channel.","Upgrade windmill-parser-java in case newer versions route output differently.","Adjust the parse input so the buffer-writing path is not reached.","Request a memory-backed stdio implementation upstream if the call site is a fixed dependency."],"exampleFix":"// before\nfwrite(out_buf, 1, out_len, stdout);\n\n// after: return the buffer to the host instead of writing to a stream\nset_result_buffer(out_buf, out_len); // exposed via wasm-bindgen","handlingStrategy":"try-catch","validationCode":"if (!input || typeof input !== 'string') throw new Error('invalid parser input');","typeGuard":null,"tryCatchPattern":"try {\n  const result = parse(input);\n} catch (e) {\n  if (String(e).includes('fwrite is not supported')) {\n    throw new Error('native component attempted buffered stream write; unsupported in parser WASM');\n  }\n  throw e;\n}","preventionTips":["Return results via memory buffers or wasm-bindgen exports instead of stream writes.","Audit native serializers for fwrite before building the WASM artifact.","Keep output paths in the host, not inside the sandbox.","Add regression tests that exercise output-producing parse paths."],"tags":["wasm","libc","stdio","fwrite","panic"],"backgroundTag":"wasm-libc-stub-panic","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"}