WebAssembly / wasi-io

I/O Types proposal for WASI
Other
144 stars 20 forks source link

Clarify poll with empty list #67

Closed badeend closed 9 months ago

badeend commented 9 months ago

The spec doesn't explicitly mention what should happen when poll is called with an empty list. Should it return immediately, block forever, or trap? With the current specification I can see people interpreting it either way. I certainly did.

I tried Googling for what native platforms do. On Windows, WSAPoll requires there to be at least one item. Linux and FreeBSD don't mention it in their documentation. Even StackOverflow etc don't have any useful info on this. So it appears that this is a pretty obscure edge case, which makes me think trapping might be the "best" option.

The current Wasmtime implementation hangs indefinitely.

pchickey commented 9 months ago

That is a really good question! My preference is to treat an empty list of pollables as an illegal input, specify that case will trap. Hanging indefinitely doesn't do any favors for either implementors or users. Compared to trapping, I'm less in favor of returning immediately, because that doesn't seem to meet the spirit of blocking until at least one pollable is ready, and so it allows users to keep the invariant that at least one element is returned.

appcypher commented 6 months ago

This issue should still be open for #69 to be merged. It was closed by the wrong PR.