Skip to content

Conversation

catamorphism
Copy link
Collaborator

@catamorphism catamorphism commented Aug 7, 2025

Port poll() to use wasip2 poll method in all cases

At this point, there should be no further uses of the preview1
component adapter for polling methods (__wasi_poll_oneoff())
when __wasilibc_use_wasip2 is defined.

Copy link
Collaborator

@pchickey pchickey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in poll_wasip2() I think that every pollable not on the ready list gets leaked. In general I think its possible to hold onto and reuse pollables for streams (and, in prior prs, streams for files/sockets) longer than this implementation does at the moment. We can leave pollable reuse for a future PR but we should fix the leaks in this one, if possible.

__wasi_event_t ev;
__wasi_errno_t error = __wasi_poll_oneoff(&sub, &ev, 1, &nevents);
return error == 0 && ev.error == 0 ? 0 : ENOTSUP;
poll_method_pollable_block(poll_borrow_pollable(pollable));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pollable gets leaked here - need to drop it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ca323cc

}
} else {
} else if (state->entry->tag == DESCRIPTOR_TABLE_ENTRY_FILE_STREAM) {
poll_pollable_drop_own(state->pollable);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file originally used only tabs, and some of your changes introduce spaces. I don't care one way or the other but its helpful if its consistent in the file

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced tabs with spaces in 40b71f6

@catamorphism catamorphism force-pushed the wasip2-porting-poll branch 2 times, most recently from 5e0771a to c42c2b9 Compare September 4, 2025 22:11
@catamorphism
Copy link
Collaborator Author

I think that every pollable not on the ready list gets leaked.

c42c2b9 should fix that.

At this point, there should be no further uses of the preview1
component adapter for polling methods (__wasi_poll_oneoff())
when __wasilibc_use_wasip2 is defined.
@catamorphism catamorphism marked this pull request as ready for review September 5, 2025 23:10
@catamorphism
Copy link
Collaborator Author

Rebased, ready for (further) review now!

@catamorphism catamorphism changed the title DRAFT: Port polling operations to wasip2 Port polling operations to wasip2 Sep 5, 2025
Copy link
Collaborator

@pchickey pchickey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The biggest thing is that we need better testing of pollables, but its difficult to impossible to do that from inside a single program, especially without sockets. But thats a big problem I don't want to gate this on, so lets get this landed and chat about how to approach that as follow-on work.

@catamorphism catamorphism merged commit d179363 into WebAssembly:main Sep 5, 2025
16 checks passed
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.

2 participants