Commit d2fb9ddd authored by Anton Bikineev's avatar Anton Bikineev Committed by V8 LUCI CQ

cppgc: shared-heap: Fix tsan race when initializing shared-heap

The race occurs when the write to instance_ happens after the static
thread-local initialization. The change simply moves the write into
CagedHeap's ctor.

Bug: chromium:1325007
No-Try: true
Change-Id: I55b6e286f311c9ddb4f3f89d12f7f9437b96cc58
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3702334
Auto-Submit: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81108}
parent 09fa6a72
......@@ -82,7 +82,6 @@ VirtualMemory ReserveCagedHeap(PageAllocator& platform_allocator) {
// static
void CagedHeap::InitializeIfNeeded(PageAllocator& platform_allocator) {
static v8::base::LeakyObject<CagedHeap> caged_heap(platform_allocator);
instance_ = caged_heap.get();
}
// static
......@@ -143,6 +142,8 @@ CagedHeap::CagedHeap(PageAllocator& platform_allocator)
kCagedHeapNormalPageReservationSize, kPageSize,
v8::base::PageInitializationMode::kAllocatedPagesMustBeZeroInitialized,
v8::base::PageFreeingMode::kMakeInaccessible);
instance_ = this;
}
void CagedHeap::NotifyLargePageCreated(LargePage* page) {
......
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