From 779aa924f6d0066fe134ccbdc2abb9e5e15e100f Mon Sep 17 00:00:00 2001 From: mlippautz Date: Mon, 11 Jan 2016 04:58:03 -0800 Subject: [PATCH] [heap] Adjust condition for AdjustLiveBytes to avoid concurrent access w/ sweeper A concurrent sweeper thread can access the same markbit cell as the main thread during right trimming a fixed array, resulting in a data race on a markbit cell. Previously we checked whether we were currently marking incrementally, filtering out this case. The current check has the benefit of keeping live_bytes accurate (modulo other bugs) until the sweeper starts. BUG=chromium:576193 LOG=N Review URL: https://codereview.chromium.org/1576853002 Cr-Commit-Position: refs/heads/master@{#33203} --- src/heap/heap.cc | 1 + src/heap/mark-compact.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/heap/heap.cc b/src/heap/heap.cc index 0ee88a0398..627a829b83 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -3109,6 +3109,7 @@ void Heap::AdjustLiveBytes(HeapObject* object, int by, InvocationMode mode) { // update while using HeapIterator because the iterator is temporarily // marking the whole object graph, without updating live bytes. if (!in_heap_iterator() && + !mark_compact_collector()->sweeping_in_progress() && Marking::IsBlack(Marking::MarkBitFrom(object->address()))) { if (mode == SEQUENTIAL_TO_SWEEPER) { MemoryChunk::IncrementLiveBytesFromGC(object, by); diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc index 6025e298ea..9ba2d5a340 100644 --- a/src/heap/mark-compact.cc +++ b/src/heap/mark-compact.cc @@ -3982,6 +3982,7 @@ void MarkCompactCollector::SweepSpaces() { MoveEvacuationCandidatesToEndOfPagesList(); { + sweeping_in_progress_ = true; { GCTracer::Scope sweep_scope(heap()->tracer(), GCTracer::Scope::MC_SWEEP_OLD); @@ -3997,7 +3998,6 @@ void MarkCompactCollector::SweepSpaces() { GCTracer::Scope::MC_SWEEP_MAP); StartSweepSpace(heap()->map_space()); } - sweeping_in_progress_ = true; if (FLAG_concurrent_sweeping) { StartSweeperThreads(); }