Skip to content

CABI: allow dropping a readable future end with a pending write - #708

Open
rvolosatovs wants to merge 1 commit into
WebAssembly:mainfrom
rvolosatovs:fix/future-drop-readable
Open

CABI: allow dropping a readable future end with a pending write#708
rvolosatovs wants to merge 1 commit into
WebAssembly:mainfrom
rvolosatovs:fix/future-drop-readable

Conversation

@rvolosatovs

Copy link
Copy Markdown
Contributor

The Explainer specifies that a component may call future.drop-readable before reading a value to signal loss of interest, in which case a blocked future.write completes with future-write-result.dropped. But SharedFutureImpl.drop asserted that any pending buffer is a WritableBuffer, i.e. a pending read, while the only pending buffer actually possible at this point is the buffer of a pending write: a reader cannot drop its end while its own read is pending (CopyEnd.drop traps while copying) and a writer cannot drop its end before the write resolves (WritableFutureEnd.drop traps unless DONE). Exercising this spec-legal path failed the assert instead of notifying the writer with DROPPED.

Flip the assert to expect a ReadableBuffer (the source buffer of the pending write), make ReadableBufferGuestImpl actually subclass ReadableBuffer (it previously only derived BufferGuestImpl, unlike WritableBufferGuestImpl, which does mix in WritableBuffer), and add a test reproducing the scenario.

The Explainer specifies that a component may call `future.drop-readable`
before reading a value to signal loss of interest, in which case a
blocked `future.write` completes with `future-write-result.dropped`. But
`SharedFutureImpl.drop` asserted that any pending buffer is a
`WritableBuffer`, i.e. a pending *read*, while the only pending buffer
actually possible at this point is the buffer of a pending *write*: a
reader cannot drop its end while its own read is pending (`CopyEnd.drop`
traps while copying) and a writer cannot drop its end before the write
resolves (`WritableFutureEnd.drop` traps unless DONE). Exercising this
spec-legal path failed the assert instead of notifying the writer with
DROPPED.

Flip the assert to expect a `ReadableBuffer` (the source buffer of the
pending write), make `ReadableBufferGuestImpl` actually subclass
`ReadableBuffer` (it previously only derived `BufferGuestImpl`, unlike
`WritableBufferGuestImpl`, which does mix in `WritableBuffer`), and add
a test reproducing the scenario.

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Assisted-by: claude:claude-fable-5
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

Successfully merging this pull request may close these issues.

1 participant