Skip to content

Sparse memory #1571

@DemiMarie

Description

@DemiMarie

One approach to solving #1397 is to make WebAssembly linear memory sparse: one can reserve terabytes (or even petabytes) of PROT_NONE address space up-front, but it must be committed before it can be used. Under this proposal, WebAssembly programs can freely mprotect() any address within the reserved range. Protecting with PROT_NONE decommits the memory, and protecting with anything else commits it.

This does allow WebAssembly modules to access decomitted memory, but that isn’t undefined behavior. It’s defined as causing a SIGSEGV, and the embedder can catch and recover from that. Embedders would need to use accessor functions to access linear memory, but that is no harder than OS kernels using them to access userspace memory. Calls into the OS kernel could pass pointers directly into linear memory, as the OS kernel already needs to be safe against concurrent reads, writes, and calls to mprotect.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions