wasmer icon indicating copy to clipboard operation
wasmer copied to clipboard

Rust's remove_dir_all is broken

Open jcaesar opened this issue 2 years ago • 1 comments

Describe the bug

fd_readdir skips cookie directory entries. cookie is just an index into the sorted list of files in the directory. If that list changes between two fd_readdir calls, cookie won't refer to the intended continuation point.

echo (wasmer -V) \| (rustc -V) \| (uname -m)
wasmer 3.1.0 | rustc 1.67.0 (fc594f156 2023-01-24) (Arch Linux rust 1:1.67.0-2) | x86_64

Steps to reproduce

Prepare the following rust program:

fn main() {
    std::fs::remove_dir_all("foo/").expect("Foo gone");
}

(result)

Execute:

cargo build --target wasm32-wasi
mkdir foo/; touch foo/{bar,blubb,gah}
wasmer run target/wasm32-wasi/debug/remove\_dir\_all.wasm --mapdir .:.

Actual behavior

thread 'main' panicked at 'Foo gone: Os { code: 55, kind: Uncategorized, message: "Directory not empty" }', src/main.rs:8:37

and the file foo/gah will still remain.

Expected behavior

foo/ removed successfully.

Additional context

  • The behavior differs with --dir and --mapdir, both are broken.
  • wasmtime seems to have the exact same bug. Made me think it's a rust bug at first.

jcaesar avatar Feb 05 '23 11:02 jcaesar

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 03 '24 21:05 stale[bot]