elliottt opened PR #8415 from elliottt:trevor/fix-p1-fd-read-mut-borrows
to bytecodealliance:main
:
In the wasi-common implementation of
fd_read
for preview1, switch to only reading the first iovec given in a vectored read. This avoids issues with Wiggle's runtiem borrow-checker implemented in #8277, which would cause the reads to unconditionally fail when two mutable borrows were taken out on the same memory.While it's not as efficient to perform a single read at a time, it is also valid, as read never promises to read all of the vectors provided.
Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
elliottt has marked PR #8415 as ready for review.
elliottt requested wasmtime-core-reviewers for a review on PR #8415.
elliottt requested alexcrichton for a review on PR #8415.
elliottt requested wasmtime-core-reviewers for a review on PR #8415.
elliottt edited PR #8415:
In the wasi-common implementation of
fd_read
for preview1, switch to only reading the first iovec given in a vectored read. This avoids issues with Wiggle's runtime borrow-checker implemented in #8277, which would cause the reads to unconditionally fail when two mutable borrows were taken out on the same memory.While it's not as efficient to perform a single read at a time, it is also valid, as read never promises to read all of the vectors provided.
Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton commented on PR #8415:
I was initially confused reading over this trying to piece together how this wasn't covered by https://github.com/bytecodealliance/wasmtime/pull/8353 but that was
fd_pread
rather thanfd_read
.Mind adding a test for this? Also, can you update the filter here to be the same as https://github.com/bytecodealliance/wasmtime/pull/8353 where it searches for the first non-empty buffer rather than the first buffer?
elliottt updated PR #8415.
elliottt commented on PR #8415:
I added a test, and verified that it failed without the fix to
fd_read
. (It's the same as the pread/pwrite test, but usingfd_seek
to polyfill their behavior.)
alexcrichton submitted PR review.
elliottt updated PR #8415.
elliottt updated PR #8415.
elliottt merged PR #8415.
Last updated: Dec 23 2024 at 12:05 UTC