Skip to content

Open directory with truncate flag crashes runtime on Windows #10577

@yagehu

Description

@yagehu

Test Case

Rust code with wasi v0.11 (for the preview1 API).

use wasi::{LOOKUPFLAGS_SYMLINK_FOLLOW, OFLAGS_TRUNC};

fn main() {
    let base_fd = 3;

    unsafe {
        let _result = wasi::path_open(
            base_fd,
            LOOKUPFLAGS_SYMLINK_FOLLOW,
            "dir",
            OFLAGS_TRUNC,
            0,
            0,
            0,
        );
    }
}

Steps to Reproduce

On Windows, set up a directory:

mkdir dir
cargo build --target wasm32-wasip1

Run the compiled Wasm binary with Wasmtime:

wasmtime --dir . target\wasm32-wasip1\debug\repro.wasm

Expected Results

The path_open call should succeed or fail.

Actual Results

Wasmtime panics with a stacktrace.

Versions and Environment

Wasmtime version or commit: v31.0.0

Operating system: Windows 11

Architecture: amd64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect behavior in the current implementation that needs fixing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions