fd_readdir(4,1065824,128,0,1047548) = 0
offset = 0 {
d_next: 0n,
d_ino: 0n,
d_namlen: 17,
d_type: 4,
name: 'run-node-wasi.mjs'
}
offset = 41 { d_next: 1n, d_ino: 0n, d_namlen: 10, d_type: 4, name: 'Cargo.toml' }
offset = 75 {
d_next: 2n,
d_ino: 0n,
d_namlen: 20,
d_type: 4,
name: 'run-wasmtime-wasi.sh'
}
(offset = 119)
Entry /run-node-wasi.mjs
Entry /Cargo.toml
Entry /run-wasmtime-wasi.sh
fd_readdir(4,1065824,128,2,1047548) = 0
offset = 0 {
d_next: 0n,
d_ino: 0n,
d_namlen: 17,
d_type: 4,
name: 'run-node-wasi.mjs'
}
offset = 41 { d_next: 1n, d_ino: 0n, d_namlen: 10, d_type: 4, name: 'Cargo.toml' }
offset = 75 {
d_next: 2n,
d_ino: 0n,
d_namlen: 20,
d_type: 4,
name: 'run-wasmtime-wasi.sh'
}
(offset = 119)
Entry /run-node-wasi.mjs
Entry /Cargo.toml
Entry /run-wasmtime-wasi.sh
fd_readdir(4,1065824,128,2,1047548) = 0
offset = 0 {
d_next: 0n,
d_ino: 0n,
d_namlen: 17,
d_type: 4,
name: 'run-node-wasi.mjs'
}
offset = 41 { d_next: 1n, d_ino: 0n, d_namlen: 10, d_type: 4, name: 'Cargo.toml' }
offset = 75 {
d_next: 2n,
d_ino: 0n,
d_namlen: 20,
d_type: 4,
name: 'run-wasmtime-wasi.sh'
}
(offset = 119)
Entry /run-node-wasi.mjs
Entry /Cargo.toml
Entry /run-wasmtime-wasi.sh
fd_readdir(4,1065824,128,2,1047548) = 0
offset = 0 {
d_next: 0n,
d_ino: 0n,
d_namlen: 17,
d_type: 4,
name: 'run-node-wasi.mjs'
}
offset = 41 { d_next: 1n, d_ino: 0n, d_namlen: 10, d_type: 4, name: 'Cargo.toml' }
offset = 75 {
d_next: 2n,
d_ino: 0n,
d_namlen: 20,
d_type: 4,
name: 'run-wasmtime-wasi.sh'
}
(offset = 119)
Entry /run-node-wasi.mjs
Entry /Cargo.toml
Entry /run-wasmtime-wasi.sh
fd_readdir(4,1065824,128,2,1047548) = 0
offset = 0 {
d_next: 0n,
d_ino: 0n,
d_namlen: 17,
d_type: 4,
name: 'run-node-wasi.mjs'
}
offset = 41 { d_next: 1n, d_ino: 0n, d_namlen: 10, d_type: 4, name: 'Cargo.toml' }
offset = 75 {
d_next: 2n,
d_ino: 0n,
d_namlen: 20,
d_type: 4,
name: 'run-wasmtime-wasi.sh'
}
(offset = 119)
Version
v19.8.1
Platform
Darwin uhyo 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000 arm64
Subsystem
No response
What steps will reproduce the bug?
Create a WASM binary that calls the fd_readdir function with a non-zero
cookieargument.Reproduction repository: https://github.com/uhyo/rust-wasi-readdir
Example Rust code that demonstrates the problem
How often does it reproduce? Is there a required condition?
always
What is the expected behavior? Why is that the expected behavior?
A typical use case of the
fd_readdirfunction is to repeatedly call it until the caller can retrieve all entries in a directory. Thecookieparameter is used as a cursor so that the function can know where in the given directory to continue from. Thefd_readdirshould respect thecookieparameter. (Read more in the reproduction repository's README)What do you see instead?
Actually, the
fd_readdirfunction ignores thecookieparameters and always returns the same set of entries. The caller falls into an infinite loop.Log of `fd_readdir` calls and how Node.js responded to them
Additional information
No response