Commit 3f65a3e1 authored by Omer Katz's avatar Omer Katz Committed by V8 LUCI CQ

[heap] Fix TSan race in HeapTest.GrowAndShrinkNewSpace

Make sure there is no background GC when setting flags.

Bug: v8:12612, v8:13185
Change-Id: I0a2d4796abe265defa00d86f826003eb048e5bf1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3829482
Auto-Submit: Omer Katz <omerkatz@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82474}
parent 6a8b90c3
......@@ -10,6 +10,7 @@
#include "include/v8-isolate.h"
#include "include/v8-object.h"
#include "src/common/assert-scope.h"
#include "src/handles/handles-inl.h"
#include "src/heap/gc-tracer.h"
#include "src/heap/memory-chunk.h"
......@@ -183,8 +184,17 @@ TEST_F(HeapTest, GrowAndShrinkNewSpace) {
if (FLAG_single_generation) return;
// Avoid shrinking new space in GC epilogue. This can happen if allocation
// throughput samples have been taken while executing the benchmark.
FLAG_predictable = true;
FLAG_stress_concurrent_allocation = false; // For SimulateFullSpace.
{
// Force an full GC and finish sweeping to make sure there is no active GC
// in the background while flags are updated.
CollectAllGarbage();
heap()->mark_compact_collector()->EnsureSweepingCompleted(
MarkCompactCollector::SweepingForcedFinalizationMode::kUnifiedHeap);
DisallowGarbageCollection no_gc_scope;
DCHECK(!heap()->incremental_marking()->IsRunning());
FLAG_predictable = true;
FLAG_stress_concurrent_allocation = false; // For SimulateFullSpace.
}
NewSpace* new_space = heap()->new_space();
if (heap()->MaxSemiSpaceSize() == heap()->InitialSemiSpaceSize()) {
......
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