Skip to content

[wasm] New failure condition introduced by anonymous mmap implementation #107215

Closed

Description

@kg

The new anonymous mmap implementation ( #101871 ) which replaces emscripten's mmap (malloc wearing a fancy hat) introduces a new failure scenario that wouldn't have failed before:

  1. Allocate ~2GB of managed objects
  2. Release the objects
  3. Force SGen to collect garbage enough so that it releases all the now-unnecessary pages it allocated. (It's possible it doesn't actually do this correctly right now...)
  4. Try to malloc 1gb of memory

In the old emscripten mmap, all sgen mmap operations and native malloc calls are all serviced by malloc under the hood, so "pages" released by munmap become available to mmap.

In the new mmap, these pages remain controlled by mmap, so emscripten malloc can't use them since it doesn't overlay on top of a real mmap implementation.

At present the workaround for this would be to disable the new mmap implementation for your application (there is a runtime option). In the long run I think the fix is to stop using emscripten malloc, and ship our own dlmalloc or mimalloc that sits on top of our mmap.

Activity

  1. added
    arch-wasm
    on Aug 30, 2024
  2. ghost added
    needs-area-label
    on Aug 30, 2024
  3. added
    untriaged
    on Aug 30, 2024
  4. dotnet-policy-service commented on Aug 30, 2024

    @dotnet-policy-service
    Contributor

    Tagging subscribers to 'arch-wasm': @lewing
    See info in area-owners.md if you want to be subscribed.

  5. added this to the 10.0.0 milestone on Aug 31, 2024
  6. added and removed
    untriaged
    needs-area-label
    on Aug 31, 2024
  7. self-assigned this
    on Oct 2, 2024
  8. added
    in-pr
    on Oct 9, 2024
  9. locked and limited conversation to collaborators on Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-wasmarea-VM-meta-monoin-pr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions