Skip to content

POSIX readv()/preadv()/writev()/pwritev() do not use all buffers under preview 2 (as found by Python) #7830

Closed as not planned

Description

@brettcannon

Test Case

TODO: upload Wasm file here

Steps to Reproduce

Expected Results

To be told 10 bytes were read/written.

Actual Results

5 bytes, which matches the first buffer, not the total bytes written across all buffers.

Versions and Environment

Wasmtime version or commit: 17.0.0

Operating system: Linux/WSL

Architecture: x64

Extra Info

Success logs when testing readv():
success-readv.txt

Failuse logs:
failure-readv.txt

Activity

  1. added
    bugIncorrect behavior in the current implementation that needs fixing
    on Jan 26, 2024
  2. changed the title [-]POSIX `readv()`/`preadv()`/`writev()`/`pwritev()` misreporting number of bytes read under preview 2 (as found by Python)[/-] [+]POSIX `readv()`/`preadv()`/`writev()`/`pwritev()` misreporting number of bytes read/written under preview 2 (as found by Python)[/+] on Jan 26, 2024
  3. brettcannon commented on Jan 26, 2024

    @brettcannon
    ContributorAuthor

    If I'm looking this up right,

    async fn fd_read<'a>(
    seems to ignore all but the first buffer.
    pub unsafe extern "C" fn fd_read(
    examines all of them.

  4. bjorn3 commented on Jan 26, 2024

    @bjorn3
    Contributor

    The preview2 based preview1 implementation which is now used by default indeed only looks at the first buffer. See also #7757. wasi-preview1-component-adapter also only looks at the first buffer as far as I can see.

  5. alexcrichton commented on Jan 26, 2024

    @alexcrichton
    Member

    Yes I can confirm that this is expected right now. It's expected that this is still posix-conformant in that posix doesn't guarantee everything is written. Vectored reads/writes aren't present in preview2 so they're polyfilled from preview1 by looking at the first buffer.

  6. brettcannon commented on Jan 26, 2024

    @brettcannon
    ContributorAuthor

    Yes I can confirm that this is expected right now.

    As in this isn't expected to change? I think I can mark those POSIX functions as unsupported in https://github.com/python/cpython/blob/main/Tools/wasm/config.site-wasm32-wasi so the tests pass if you plan to keep the current semantics.

  7. alexcrichton commented on Jan 28, 2024

    @alexcrichton
    Member

    Correct yeah, that's not expected to change.

  8. changed the title [-]POSIX `readv()`/`preadv()`/`writev()`/`pwritev()` misreporting number of bytes read/written under preview 2 (as found by Python)[/-] [+]POSIX `readv()`/`preadv()`/`writev()`/`pwritev()` do not use all buffers under preview 2 (as found by Python)[/+] on Jan 29, 2024
  9. brettcannon commented on Jan 29, 2024

    @brettcannon
    ContributorAuthor

    I've tweaked the title and closing this as it's working as intended. I'll patch CPython to consider these functions as unavailable.

  10. added 2 commits that reference this issue on Mar 1, 2024
  11. added 2 commits that reference this issue on Mar 2, 2024
  12. added a commit that references this issue on Mar 2, 2024
  13. 2 remaining items

  14. added a commit that references this issue on Mar 4, 2024
  15. added a commit that references this issue on Mar 25, 2024
  16. added a commit that references this issue on Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect behavior in the current implementation that needs fixing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions