Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flush cause pollable to hang #550

Open
peter-jerry-ye opened this issue Jan 27, 2025 · 1 comment
Open

flush cause pollable to hang #550

peter-jerry-ye opened this issue Jan 27, 2025 · 1 comment

Comments

@peter-jerry-ye
Copy link
Contributor

peter-jerry-ye commented Jan 27, 2025

Description

Flush, then poll on the stdout, will cause the program to hang.

Expected behavior

The program finishes, as wasmtime's behavior.

Steps to reproduce:

  • run cargo component new flush --lib && cd flush
  • update deps.toml and run wit-deps update:
    cli = "https://github.com/Webassembly/wasi-cli/archive/refs/tags/v0.2.0.tar.gz"
  • update world.wit (and deps.toml) to:
    package component:flush;
    
    /// An example world for the component to target.
    world example {
        include wasi:cli/command@0.2.0;
    }
  • append to Cargo.toml
    [package.metadata.component.target.dependencies]
    "wasi:random" = { path = "wit/deps/random" }
    "wasi:cli" = { path = "wit/deps/cli" }
    "wasi:io" = { path = "wit/deps/io" }
    "wasi:clocks" = { path = "wit/deps/clocks" }
    "wasi:filesystem" = { path = "wit/deps/filesystem" }
    "wasi:sockets" = { path = "wit/deps/sockets" }
  • Modify src/lib.rs
    #[allow(warnings)]
    mod bindings;
    
    use bindings::wasi;
    
    use crate::bindings::exports::wasi::cli::run::Guest;
    
    struct Component;
    
    impl Guest for Component {
        fn run() -> Result<(), ()> {
            let stdout = wasi::cli::stdout::get_stdout();
            stdout.flush().unwrap();
            let poll = stdout.subscribe();
            poll.block();
            Ok(())
        }
    }
    
    bindings::export!(Component with_types_in bindings);
  • run cargo component build
  • run wasmtime run target/wasm32-wasip1/debug/flush.wasm and jco run target/wasm32-wasip1/debug/flush.wasm
@vados-cosmonic
Copy link
Contributor

Hey @peter-jerry-ye a bit late here, but thanks for reporting this -- will try to build it & reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants