{"record":{"id":"bb0dbd06e61977fd","repo":"windmill-labs/windmill","slug":"fdopen-is-not-supported","errorCode":null,"errorMessage":"fdopen is not supported","messagePattern":"fdopen is not supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-csharp/src/wasm_libc.rs","lineNumber":165,"sourceCode":"\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,\n) -> usize {\n    panic!(\"fwrite is not supported\");\n}\n\n#[no_mangle]","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-csharp/src/wasm_libc.rs#L147-L183","documentation":"fdopen() is a deliberate panic stub in wasm_libc.rs (\"fdopen is not supported\"). WASM has no file descriptors, so wrapping one in a FILE* is impossible. Any call to fdopen aborts the WASM execution immediately.","triggerScenarios":"Runtime or native code calls fdopen(fd, mode) to attach a stdio stream to file descriptor 0/1/2 (classic stdout/stderr bootstrap) or to open a pipe/socket descriptor.","commonSituations":"Runtime startup code wiring stdout/stderr FILE objects from fds; C libraries opening descriptors for I/O; mono paths that re-open streams.","solutions":["Prevent the runtime from calling fdopen by configuring stream initialization off in the WASM build.","Stub fdopen to return a null FILE pointer with graceful caller-side failure handling.","Implement a minimal fdopen backed by an in-memory/console sink if callers expect stdout/stderr.","Remove the native dependency that requires fd-based streams."],"exampleFix":"// before\nFILE* f = fdopen(1, \"w\");\n// after\n// use a host-provided console writer instead of fd-backed streams","handlingStrategy":"validation","validationCode":"// Confirm the wasm runtime never opens fd-backed streams at startup:\nif (isWasmHost) {\n  runtimeConfig.wireStdioFromFds = false; // avoids fdopen(0/1/2)\n}","typeGuard":null,"tryCatchPattern":"try {\n  runInWasmParser(code);\n} catch (e) {\n  if (String(e?.message ?? e).includes(\"fdopen is not supported\")) {\n    console.warn(\"fdopen is unsupported in wasm; streams must not be built from file descriptors.\");\n  } else {\n    throw e;\n  }\n}","preventionTips":["Never open file descriptors in code intended for the wasm host.","Stub fdopen to return null with graceful failure in wasm_libc.rs if callers can handle it.","Avoid native libraries that re-open stdout/stderr from fds.","Document fd-based I/O as unsupported in the parser runtime."],"tags":["wasm","libc","csharp","file-io","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"}