Skip to content

Add MAP_ANON support for mmap/munmap for standalone Wasm #16280

Closed
@bryanmcquade

Description

@bryanmcquade

Sam Clegg asked me to open an issue to extend the current support for MAP_ANON that was added in

// MAP_ANONYMOUS (aka MAP_ANON) isn't actually defined by POSIX spec,
// but it is widely used way to allocate memory pages on Linux, BSD and Mac.
// In this case fd argument is ignored.
if ((flags & {{{ cDefine('MAP_ANONYMOUS') }}}) !== 0) {
ptr = mmapAlloc(len);
if (!ptr) return -{{{ cDefine('ENOMEM') }}};
allocated = true;
} else {
to also work for standalone wasm.

The motivation for this is that I (and others) use the abseil library in standalone wasm, and abseil depends on mmap availability in one of its low level routines, used by things like lock acquires in debug builds (among other cases), which are widely depended on by various features across abseil. The specific abseil code that calls mmap is here: https://github.com/abseil/abseil-cpp/blob/1ae9b71c474628d60eb251a3f62967fe64151bb2/absl/base/internal/low_level_alloc.cc#L562

Metadata

Metadata

Assignees

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