{"record":{"id":"0eb8135ed7f295ac","repo":"windmill-labs/windmill","slug":"fdopen-is-not-supported-0eb813","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-java/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-java/src/wasm_libc.rs#L147-L183","documentation":"The `fdopen` stub panics: associating a C stream with a file descriptor is unimplemented in the WASM libc shim. The sandbox has no real file descriptors, so the symbol is exported only for linkage and any runtime call is a fatal unsupported-operation panic.","triggerScenarios":"Code compiled into the parser's WASM module calls `fdopen(fd, mode)` — usually to wrap a descriptor for reading or writing after a native open() call.","commonSituations":"Native components attempting real file I/O inside the sandbox; code that opens temp files or pipes and then stream-wraps the descriptor; dependencies assuming a full POSIX libc.","solutions":["Remove the file-descriptor code path from the component compiled into the module; use in-memory buffers instead.","Check whether the triggering input can be processed without the file I/O path (e.g. pass content directly rather than via file).","Upgrade windmill-parser-java in case newer builds provide a memory-backed fdopen.","Report the gap upstream if a third-party dependency requires fdopen."],"exampleFix":"// before\nFILE *f = fdopen(fd, \"rb\");\nfread(buf, 1, n, f);\n\n// after: operate on the in-memory buffer directly\nmemcpy(buf, mem_ptr, n); // no FILE* involved in WASM","handlingStrategy":"validation","validationCode":"// Reject inputs/paths that would push the parser into file-descriptor handling; pass content in memory instead.\nif (requiresFileAccess(input)) throw new Error('parser input must not require file descriptors');","typeGuard":"function isInlineData(x) {\n  return typeof x === 'string' || x instanceof Uint8Array;\n}","tryCatchPattern":"try {\n  const result = parse(inlineInput);\n} catch (e) {\n  if (String(e).includes('fdopen is not supported')) {\n    throw new Error('parser attempted file-descriptor I/O; unsupported in WASM sandbox');\n  }\n  throw e;\n}","preventionTips":["Always pass parse inputs as in-memory strings/bytes, never as file paths.","Avoid native components that open files or pipes inside the sandbox.","Document that fd/fopen/fdopen/fclose are link-only stubs in this module.","Request memory-backed stdio shims upstream if file-like I/O is needed."],"tags":["wasm","libc","file-io","fdopen","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-08T15:18:49.778Z"}