Skip to content

inconsistent poll_oneoff behavior #2399

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

Open
peter-jerry-ye opened this issue May 6, 2025 · 1 comment
Open

inconsistent poll_oneoff behavior #2399

peter-jerry-ye opened this issue May 6, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@peter-jerry-ye
Copy link

peter-jerry-ye commented May 6, 2025

Describe the bug
The poll_oneoff returned a clock event that has not yet finished

To Reproduce

I attached the poll.wat at the end

wasm-tools parse poll.wat -o poll.wasm
wazero run poll.wasm
wasmtime poll.wasm

Expected behavior
The program does not panic, that is the returned result array should have length of 1 instead of 2

Screenshots
N.A.

Environment (please complete the relevant information):

  • Go version: N.A.
  • wazero Version: 1.9.0
  • Host architecture: Mac Arm 64
  • Runtime mode: compiler

Downloaded from GitHub Release

Additional context

(module
    (func $poll_oneoff (import "wasi_snapshot_preview1" "poll_oneoff") (param i32 i32 i32 i32) (result i32))
    (memory (export "memory") 1)
    (func $start (export "_start")
        ;; Define two clock subscriptions
        ;; clock 0
        (i64.store (i32.const 0) (i64.const 0)) ;; USER DATA
        (i32.store (i32.const 8) (i32.const 0)) ;; TAG FOR CLOCK
        (i32.store (i32.const 16) (i32.const 1)) ;; CLOCK ID : Monotonic
        (i64.store (i32.const 24) (i64.const 1000000000)) ;; TIMEOUT : 1 second
        (i64.store (i32.const 32) (i64.const 1)) ;; PRECISION
        (i32.store (i32.const 40) (i32.const 0)) ;; FLAG : Relative time
        ;; clock 1
        (i64.store (i32.const 48) (i64.const 0)) ;; USER DATA
        (i32.store (i32.const 56) (i32.const 0)) ;; TAG FOR CLOCK
        (i32.store (i32.const 64) (i32.const 1)) ;; CLOCK ID : Monotonic
        (i64.store (i32.const 72) (i64.const 1000000000000)) ;; TIMEOUT : 1000 second
        (i64.store (i32.const 80) (i64.const 1)) ;; PRECISION
        (i32.store (i32.const 88) (i32.const 0)) ;; FLAG : Relative time
        
        ;; Call poll_oneoff
        (call $poll_oneoff
            (i32.const 0) ;; SUBSCRIPTION ARRAY
            (i32.const 104) ;; RESULT ARRAY
            (i32.const 2) ;; NUMBER OF SUBSCRIPTIONS
            (i32.const 96) ;; size
        )
        (if (i32.eqz)
            (then
                (i32.load (i32.const 96))
                (if (i32.eq (i32.const 2))
                    (then
                        (unreachable)
                    )
                )        
            )
        )
    )
)
@peter-jerry-ye peter-jerry-ye added the bug Something isn't working label May 6, 2025
@evacchi
Copy link
Contributor

evacchi commented May 13, 2025

thanks for the report, I'll try to take a look soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants