jellevandenhooff opened PR #12631 from jellevandenhooff:fix-subtask-cancel-borrow-release to bytecodealliance:main:
Update the component model resource tracking to handle cancelling host tasks. I ran into this when cancelling a read on a UDP socket and then trying to drop the socket afterwards. Before this change, that did not work because the cancelled read still held on to the socket.
I debugged this issue and wrote the code with Claude. I've tested this code for my use case and it seems to work, but I don't fully understand the implications. I worry that it might not be safe to release the borrow count because maybe the host function can still run.
jellevandenhooff requested wasmtime-core-reviewers for a review on PR #12631.
jellevandenhooff requested alexcrichton for a review on PR #12631.
jellevandenhooff updated PR #12631.
jellevandenhooff edited PR #12631:
Update the component model resource tracking to handle cancelling host tasks. Before this change, when cancelling a read on a UDP socket and then dropping the socket failed because of outstanding borrows: the read never released its borrow. Now it does.
I debugged this issue and wrote the code with Claude. I've tested this code for my use case and it seems to work, but I don't fully understand the implications. I worry that it might not be safe to release the borrow count because maybe the host function can still run.
github-actions[bot] added the label wasmtime:api on PR #12631.
alexcrichton commented on PR #12631:
Thanks for the PR! Definitely looks like wrong behavior here, especially as the test shows. The fix isn't quite what I would have in mind for this, however, so I'll work a bit locally to see if I can't get something working. I'll likely have a sibling PR to this which includes your test as well. Will post back here when that's ready.
alexcrichton commented on PR #12631:
Ok I've pushed up a "more official fix" to https://github.com/bytecodealliance/wasmtime/pull/12640 which includes the tests here and should resolve them. Thanks again @jellevandenhooff!
jellevandenhooff closed without merge PR #12631.
Last updated: Feb 24 2026 at 04:36 UTC