Skip to content

Ownership model for streams is not clear. #822

Closed

Description

@brendandburns

When reading from a stream, it seems that the list that is returned from a stream is owned by the caller, but that is not clearly spelled out in the documentation.

Activity

  1. lukewagner commented on Mar 6, 2023

    @lukewagner
    Member

    The ownership of memory is not something specific to the wasi-http/wasi-io proposals, but rather defined by the Canonical ABI based purely on the types involved. For list<u8>, if you look at store_list in CanonicalABI.md, it describes how the core module's exported cabi_realloc function is called to allocate the memory, which is written into by the host, and then the pointer is returned to the core module. The C headers for the ownership semantics could be generated per-interface by wit-bindgen, though.

  2. brendandburns commented on Mar 7, 2023

    @brendandburns
    ContributorAuthor

    I was suggesting that the streams wit definition should add clarity in the comments about how this is expected to work.

  3. lukewagner commented on Mar 8, 2023

    @lukewagner
    Member

    Improving documentation is a good idea, but I don't know if the Wit document is the right place since this ends up being for many guest/host languages, a bindings-internal detail (e.g., JS will simply see a JS array pop out). But perhaps this could be usefully generated as part of the ABI documentation or, perhaps better, in the generated C header comments. @sunfishcode was thinking about this too recently, so that we're not having to send folks to read Canonical ABI all the time.

  4. brendandburns commented on Mar 8, 2023

    @brendandburns
    ContributorAuthor

    In garbage collected languages, the ownership is clearly not as important, but in non-gc languages like C it is a question that someone asks whenever they see a pointer as a return value.

  5. lukewagner commented on Mar 10, 2023

    @lukewagner
    Member

    Even for explicitly-managed languages like C++/Rust, the ownership transfer should be made explicit in the return types of the generated bindings (e.g., a std::vector return-by-value). Also, when wasm-gc is integrated by adding new canonopts, the core wasm signature won't even return an i32 pointer, but rather some sort of wasm-GC reference type. Thus, this does seem to be something most appropriate in a generated C header file or perhaps a generated ABI doc.

  6. added
    S-inactiveStatus: no discussion in over a year. Records silence during triage; not a proposal to close.
    on Aug 20, 2026
  7. sw17ch commented on Oct 8, 2026

    @sw17ch

    The WASI HTTP champions looked at this in triage. WASIp3 streams, we believe, have solved or have ongoing work to solve all these issues.

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

    P-httpProposal: wasi-httpS-inactiveStatus: no discussion in over a year. Records silence during triage; not a proposal to close.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions