Skip to content

OCaml's Bigarray module can't handle large linear memory sizes #80

Closed

Description

@sunfishcode

memory.ml is currently using OCaml's Bigarray module, specifically Bigarray.Array1, to represent linear memory.

Bigarray's interfaces all use OCaml's int type for array extents and index values. While int has a host-dependent size, it is 31 bits on some common systems. It is also signed, so it can only hold values less than 1<<30.

Consequently, on 32-bit hosts, it seems the WebAssembly reference interpreter is limited to linear memory sizes less than 1 GiB, even when the underlying host is capable of allocating that much memory.

Am I understanding everything here correctly? And if so, are there any alternatives to Bigarray which allow for bigger sizes?

Activity

  1. sunfishcode commented on Sep 18, 2015

    @sunfishcode
    MemberAuthor

    One more note: I noticed this while working on wasm's integer operator semantics, and noticed that address_of_value currently does Int32.to_int i, which silently wraps if the value is outside the OCaml int range, which is not the intended semantics.

  2. rossberg commented on Sep 21, 2015

    @rossberg
    Member
  3. lukewagner commented on Oct 29, 2015

    @lukewagner
    Member

    I consider this basically resolved by #108 which at least confines the hand waving to one well-commented block.

  4. added a commit that references this issue on Nov 19, 2019
  5. added a commit that references this issue on Sep 4, 2024
  6. added a commit that references this issue on Nov 12, 2025
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions