Skip to content

shared memory: no way to report memory growth failure #4240

Open

Description

@abrown

In certain cases, a shared memory will not have an associated store. A ResourceLimiter is attached to a store to not only constrain the resources use but also accept certain error scenarios, e.g., when a memory growth operation fails. If memory growth fails for a shared memory, some code should handle the error but as of #4187 there is no mechanism to do so.

Activity

  1. added
    wasm-proposal:threads
    on Jun 8, 2022
  2. abrown commented on Jun 30, 2022

    @abrown
    MemberAuthor

    @alexcrichton, should the resolution of this just be to return an error if no Store (and thus ResourceLimiter) are available? E.g.:

    if new_byte_size > max {
      if let Some(store) = store {
        store.memory_grow_failed(&format_err!("Memory maximum size exceeded"));
      } else {
        bail!("Memory maximum size exceeded");
      }
      return Ok(None);
    }
  3. alexcrichton commented on Jun 30, 2022

    @alexcrichton
    Member

    I don't think so because that would translate to a trap rather than a -1 return value from memory.grow. Additionally the more worrisome case for me is this one where there's no embedder-defined way to limit the growth of a shared memory like there is a way to limit the growth of a non-shared memory.

  4. abrown commented on Jun 30, 2022

    @abrown
    MemberAuthor

    Hm. I had originally thought that a) the ResourceLimiter would have to be disconnected from a Store or b) the shared memory would have to be associated with a store--neither of these seems great... or easy. What do you think?

  5. alexcrichton commented on Jul 1, 2022

    @alexcrichton
    Member

    I don't personally know how best to solve this, and I suspect that reusing what we have today probably won't cut it and this'll need some sort of new abstraction or something like that.

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

    wasm-proposal:threads

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions