Commit 37693e0a authored by Eric Holk's avatar Eric Holk Committed by Commit Bot

[wasm] Use V8::FatalProcessOutOfMemory when SetPermissions fails

SetPermissions causes memory that was previously reserved but uncommitted to be
committed. This could put us over the committed memory limit for the process,
causing SetPermissions to fail. In this case, we should report this as an out of
memory error rather than a crash.

Bug: chromium:838880
Change-Id: I2785aa9f5608fa04196fee2b280e0c6df2f56ca8
Reviewed-on: https://chromium-review.googlesource.com/1040657Reviewed-by: 's avatarDeepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Eric Holk <eholk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52928}
parent 11f576d1
......@@ -72,8 +72,13 @@ void* TryAllocateBackingStore(WasmMemoryTracker* memory_tracker, Heap* heap,
// Make the part we care about accessible.
if (size > 0) {
CHECK(SetPermissions(memory, RoundUp(size, kWasmPageSize),
PageAllocator::kReadWrite));
bool result = SetPermissions(memory, RoundUp(size, kWasmPageSize),
PageAllocator::kReadWrite);
// SetPermissions commits the extra memory, which may put us over the
// process memory limit. If so, report this as an OOM.
if (!result) {
V8::FatalProcessOutOfMemory(nullptr, "TryAllocateBackingStore");
}
}
memory_tracker->RegisterAllocation(*allocation_base, *allocation_length,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment