Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

wasi-preview1-component-adapter: unreachable in Descriptors::open when opening a file while nested files are open (freelist points to an open descriptor)

Aperta
#14,794 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust, wasm

Direzione di ricerca

Start with crates/wasi-preview1-component-adapter/src/descriptors.rs, especially Descriptors::open and the unreachable! path mentioned in the report. Reproduce the nested fopen case using the provided Yosys/npm example, then trace descriptor allocation and freelist bookkeeping when files remain open. Done means the nested case no longer traps, the misleading unreachable message is addressed, and the behavior is covered by an appropriate regression test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

The WASI preview1 component adapter traps with unreachable in Descriptors::open when a program opens a file while a few other files are still open, nested. As whitequark noted in the downstream report, the trap is probably this unreachable!: https://github.com/bytecodealliance/wasmtime/blob/main/crates/wasi-preview1-component-adapter/src/descriptors.rs#L310. Its message is also misleading: it should say that the freelist points to an open descriptor.

Downstream report, with the discussion: https://codeberg.org/YoWASP/yosys/issues/41 (YoWASP Yosys: Yosys + ABC compiled to WASI, adapted to a component with the preview1 adapter, and run in Node through jco).

Reproduction

@yowasp/yosys 0.68.1207 and 0.70.1258, Node 25:

import { runYosys } from '@yowasp/yosys';

const files = {
  't.v': 'module top(input a, b, c, output y); assign y = (a & b) | c; endmodule\n',
  'lut.lib': '1 1 1\n2 1 1\n3 1 1\n4 1 1\n',
  'x.abc': 'read_lut lut.lib\n',
};
// traps: RuntimeError: unreachable
await runYosys(['-p', 'read_verilog t.v; proc; techmap; abc -script x.abc'], files);
// works: the same command given inline
await runYosys(['-p', 'read_verilog t.v; proc; techmap; abc -script +read_lut,lut.lib;strash;if'], files);

The two calls differ in nesting. In the first, Yosys's ABC script sources x.abc, whose file is still open, and read_lut then calls fopen on lut.lib. In the second there is one source level less, and the same fopen works. A missing file (read_lut nothing.lib) gives ABC's normal "Cannot open input file" error, not a trap. Native Yosys runs both without error.

Backtrace (Node, @yowasp/yosys 0.70.1258)
RuntimeError: unreachable
    at _ZN22wasi_snapshot_preview111descriptors11Descriptors4open17hf43b776c170aa288E (wasm://wasm/00021de6:wasm-function[102]:0x4cac)
    at path_open (wasm://wasm/00021de6:wasm-function[78]:0x3472)
    at wasm://wasm/c8fd64d6:wasm-function[18]:0x317
    at yosys.wasm.__wasi_path_open (wasm-function[46148]:0x2875534)
    at yosys.wasm.__wasilibc_nocwd_openat_nomode (wasm-function[46157]:0x28756da)
    at yosys.wasm.__wasilibc_open_nomode (wasm-function[46174]:0x287620a)
    at yosys.wasm.fopen (wasm-function[46359]:0x28816ad)
    at yosys.wasm.abc::If_CommandReadLut(abc::Abc_Frame_t_*, int, char**) (wasm-function[23010]:0x1828002)
    at yosys.wasm.abc::CmdCommandDispatch(...)
    at yosys.wasm.abc::Cmd_CommandExecute(...)
    at yosys.wasm.abc::CmdCommandSource(abc::Abc_Frame_t_*, int, char**) (wasm-function[19831]:0x14b75c8)
    at yosys.wasm.abc::CmdCommandDispatch(...)
    at yosys.wasm.abc::Cmd_CommandExecute(...)
    at yosys.wasm.abc::CmdCommandSource(abc::Abc_Frame_t_*, int, char**) (wasm-function[19831]:0x14b75c8)
    at yosys.wasm.abc::CmdCommandDispatch(...)
    at yosys.wasm.abc::Cmd_CommandExecute(...)
    at yosys.wasm.abc::Abc_RealMain(int, char**) (wasm-function[21311]:0x1618f7e)
    at yosys.wasm.(anonymous namespace)::RunAbcState::run(...)
    at yosys.wasm.(anonymous namespace)::AbcPass::execute(...)
    at yosys.wasm.Yosys::Pass::call(...)
    at yosys.wasm.Yosys::run_pass(...)
    at yosys.wasm.main (wasm-function[4355]:0x3e41d4)
    at yosys.wasm._start (wasm-function[30]:0x12624)
    at wasi:cli/[email protected]#run (wasm://wasm/00021de6:wasm-function[51]:0xdba)

I don't know which adapter version YoWASP's build uses. It is reproducible with the published npm packages above. A downstream workaround exists (passing the commands inline), so this is not urgent for us. Still, the trap and its message look like an adapter bug in the descriptor freelist's bookkeeping when files are opened and closed in this nested pattern.

Lingua principale
Rust
Stelle
18.7k
Fork
1.9k
Merge medio
19h 26m
PR unite (30g)
355

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bytecodealliance/wasmtime

Tutte le issue di bytecodealliance/wasmtime

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.