Index: compiler-rt/lib/scudo/standalone/common.h =================================================================== --- compiler-rt/lib/scudo/standalone/common.h +++ compiler-rt/lib/scudo/standalone/common.h @@ -149,6 +149,7 @@ #define MAP_NOACCESS (1U << 1) #define MAP_RESIZABLE (1U << 2) #define MAP_MEMTAG (1U << 3) +#define MAP_PRECOMMIT (1U << 4) // Our platform memory mapping use is restricted to 3 scenarios: // - reserve memory at a random address (MAP_NOACCESS); Index: compiler-rt/lib/scudo/standalone/fuchsia.cpp =================================================================== --- compiler-rt/lib/scudo/standalone/fuchsia.cpp +++ compiler-rt/lib/scudo/standalone/fuchsia.cpp @@ -112,6 +112,17 @@ dieOnMapUnmapError(Status == ZX_ERR_NO_MEMORY ? Size : 0); return nullptr; } + + if (Flags & MAP_PRECOMMIT) { + Status = _zx_vmo_op_range(Vmo, ZX_VMO_OP_COMMIT, VmoSize, Size, + /*buffer=*/nullptr, /*buffer_size=*/0); + } + if (UNLIKELY(Status != ZX_OK)) { + if (Status != ZX_ERR_NO_MEMORY || !AllowNoMem) + dieOnMapUnmapError(Status == ZX_ERR_NO_MEMORY ? Size : 0); + return nullptr; + } + if (Data) Data->VmoSize += Size; Index: compiler-rt/lib/scudo/standalone/release.h =================================================================== --- compiler-rt/lib/scudo/standalone/release.h +++ compiler-rt/lib/scudo/standalone/release.h @@ -109,7 +109,7 @@ } else { Buffer = reinterpret_cast( map(nullptr, roundUpTo(BufferSize, getPageSizeCached()), - "scudo:counters", MAP_ALLOWNOMEM, &MapData)); + "scudo:counters", MAP_ALLOWNOMEM | MAP_PRECOMMIT, &MapData)); } }