wasi-preview1-component-adapter: unreachable in Descriptors::open when opening a file while nested files are open (freelist points to an open descriptor)
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
- Ambito
- backend, operating-systems
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
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di bytecodealliance/wasmtime
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
bytecodealliance/wasmtime#14894 ·
I maintainer di solito rispondono entro 1 giorno
-
bug wasm-proposal:exceptions wasmtime:debugging
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
bytecodealliance/wasmtime#14102 ·
I maintainer di solito rispondono entro 1 giorno
-
wasm-proposal:gc
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
bytecodealliance/wasmtime#13808 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
cranelift cranelift:area:clif cranelift:goal:optimize-speed enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
bytecodealliance/wasmtime#1598 · 9 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 55/100
bytecodealliance/wasmtime#14893 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di bytecodealliance/wasmtime
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
chrisdickinson/trivia#26 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100