Commit 88a5983d authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[wasm] Print code space size on OOM

If we hit an OOM when allocating the code space for a Wasm module,
include the code size we tried to allocate in the error message. This
should make crash reports easier to diagnose.

R=ecmziegler@chromium.org

Bug: chromium:1302310
Change-Id: I0a85caff65efcad122664765c07f78b35095097e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3506993Reviewed-by: 's avatarEmanuel Ziegler <ecmziegler@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79402}
parent 35e6a110
......@@ -2194,7 +2194,13 @@ std::shared_ptr<NativeModule> WasmCodeManager::NewNativeModule(
// If we cannot allocate enough code space, fail with an OOM message.
if (code_vmem_size < min_code_size) {
V8::FatalProcessOutOfMemory(isolate, "NewNativeModule");
constexpr auto format = base::StaticCharVector(
"NewNativeModule cannot allocate required minimum (%zu)");
constexpr int kMaxMessageLength =
format.size() - 3 + std::numeric_limits<size_t>::digits10;
base::EmbeddedVector<char, kMaxMessageLength + 1> message;
SNPrintF(message, format.begin(), min_code_size);
V8::FatalProcessOutOfMemory(isolate, message.begin());
UNREACHABLE();
}
......@@ -2207,7 +2213,13 @@ std::shared_ptr<NativeModule> WasmCodeManager::NewNativeModule(
code_space = TryAllocate(code_vmem_size);
if (code_space.IsReserved()) break;
if (retries == kAllocationRetries) {
V8::FatalProcessOutOfMemory(isolate, "NewNativeModule");
constexpr auto format = base::StaticCharVector(
"NewNativeModule cannot allocate code space of %zu bytes");
constexpr int kMaxMessageLength =
format.size() - 3 + std::numeric_limits<size_t>::digits10;
base::EmbeddedVector<char, kMaxMessageLength + 1> message;
SNPrintF(message, format.begin(), code_vmem_size);
V8::FatalProcessOutOfMemory(isolate, message.begin());
UNREACHABLE();
}
// Run one GC, then try the allocation again.
......
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