Commit 084207d9 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Use engine's allocator consistently

Using the Isolate's allocator when creating the WasmModule can lead to
use-after-free situations when the NativeModule is shared across
Isolates.

R=mstarzinger@chromium.org

Bug: v8:9079
Change-Id: I5a564852179cc5b9d4cbad2a002d3b6e14b01968
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1550404Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60605}
parent ab55cc73
......@@ -613,9 +613,10 @@ MaybeHandle<WasmModuleObject> DeserializeNativeModule(
ModuleWireBytes wire_bytes(wire_bytes_vec);
// TODO(titzer): module features should be part of the serialization format.
WasmFeatures enabled_features = WasmFeaturesFromIsolate(isolate);
ModuleResult decode_result = DecodeWasmModule(
enabled_features, wire_bytes.start(), wire_bytes.end(), false,
i::wasm::kWasmOrigin, isolate->counters(), isolate->allocator());
ModuleResult decode_result =
DecodeWasmModule(enabled_features, wire_bytes.start(), wire_bytes.end(),
false, i::wasm::kWasmOrigin, isolate->counters(),
isolate->wasm_engine()->allocator());
if (decode_result.failed()) return {};
CHECK_NOT_NULL(decode_result.value());
WasmModule* module = decode_result.value().get();
......
......@@ -264,7 +264,7 @@ size_t GetFunctionOffset(i::Isolate* isolate, const uint8_t* buffer,
size_t size, size_t index) {
ModuleResult result = DecodeWasmModule(
kAllWasmFeatures, buffer, buffer + size, false, ModuleOrigin::kWasmOrigin,
isolate->counters(), isolate->allocator());
isolate->counters(), isolate->wasm_engine()->allocator());
CHECK(result.ok());
const WasmFunction* func = &result.value()->functions[1];
return func->code.offset();
......
......@@ -46,7 +46,7 @@ std::shared_ptr<WasmModule> DecodeWasmModuleForTesting(
auto enabled_features = WasmFeaturesFromIsolate(isolate);
ModuleResult decoding_result = DecodeWasmModule(
enabled_features, module_start, module_end, verify_functions, origin,
isolate->counters(), isolate->allocator());
isolate->counters(), isolate->wasm_engine()->allocator());
if (decoding_result.failed()) {
// Module verification failed. throw.
......
......@@ -116,7 +116,8 @@ void GenerateTestCase(Isolate* isolate, ModuleWireBytes wire_bytes,
auto enabled_features = i::wasm::WasmFeaturesFromIsolate(isolate);
ModuleResult module_res = DecodeWasmModule(
enabled_features, wire_bytes.start(), wire_bytes.end(), kVerifyFunctions,
ModuleOrigin::kWasmOrigin, isolate->counters(), isolate->allocator());
ModuleOrigin::kWasmOrigin, isolate->counters(),
isolate->wasm_engine()->allocator());
CHECK(module_res.ok());
WasmModule* module = module_res.value().get();
CHECK_NOT_NULL(module);
......
......@@ -186,7 +186,7 @@ class WasmModuleVerifyTest : public TestWithIsolateAndZone {
}
ModuleResult result = DecodeWasmModule(
enabled_features_, temp, temp + total, false, kWasmOrigin,
isolate()->counters(), isolate()->allocator());
isolate()->counters(), isolate()->wasm_engine()->allocator());
delete[] temp;
return result;
}
......@@ -194,7 +194,7 @@ class WasmModuleVerifyTest : public TestWithIsolateAndZone {
const byte* module_end) {
return DecodeWasmModule(enabled_features_, module_start, module_end, false,
kWasmOrigin, isolate()->counters(),
isolate()->allocator());
isolate()->wasm_engine()->allocator());
}
};
......
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