Commit df591efb authored by Etienne Pierre-doray's avatar Etienne Pierre-doray Committed by Commit Bot

[test]: Fix platform lifetime in EagerUnmappingInCollectAllAvailableGarbage.

Currently MockPlatformForUnmapper has shorter lifetime than the isolate that
uses it. This leads to use-after-free races in concurrent tasks that fetch
the mock platform just before it is freed.

This CL ensures that MockPlatformForUnmapper is valid throughout the whole
lifetime of the isolate

Change-Id: I94a658bf7eb70d924a19522dab09744f21782972
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2502809Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70826}
parent 22fead0c
......@@ -50,14 +50,24 @@ class MockPlatformForUnmapper : public TestPlatform {
v8::Platform* old_platform_;
};
TEST(EagerUnmappingInCollectAllAvailableGarbage) {
UNINITIALIZED_TEST(EagerUnmappingInCollectAllAvailableGarbage) {
FLAG_stress_concurrent_allocation = false; // For SimulateFullSpace.
CcTest::InitializeVM();
MockPlatformForUnmapper platform;
Heap* heap = CcTest::heap();
i::heap::SimulateFullSpace(heap->old_space());
CcTest::CollectAllAvailableGarbage();
CHECK_EQ(0, heap->memory_allocator()->unmapper()->NumberOfChunks());
v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
v8::Isolate* isolate = v8::Isolate::New(create_params);
{
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> context = CcTest::NewContext(isolate);
v8::Context::Scope context_scope(context);
Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
Heap* heap = i_isolate->heap();
i::heap::SimulateFullSpace(heap->old_space());
CcTest::CollectAllAvailableGarbage(i_isolate);
CHECK_EQ(0, heap->memory_allocator()->unmapper()->NumberOfChunks());
}
isolate->Dispose();
}
} // namespace heap
......
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