[K/N] Fix a race on mark queue destruction in CMS GC

Merge-request: KT-MR-14076
This commit is contained in:
Aleksei.Glushko
2024-03-11 10:47:03 +01:00
committed by Space Team
parent fb7176d5fa
commit 651f068e06
@@ -78,11 +78,9 @@ void gc::mark::ConcurrentMark::runMainInSTW() {
} }
} while (!tryTerminateMark(everSharedBatches)); } while (!tryTerminateMark(everSharedBatches));
for (auto& thread : *lockedMutatorsList_) { // By this point mutator mark queues may not be populated anymore.
thread.gc().impl().gc().mark().markQueue().destroy(); // However, some threads may still try to enqueue a marked object, before they observe the barrier disablement.
} // Thus, mark queue destruction takes place only later below.
endMarkingEpoch();
gc::processWeaks<DefaultProcessWeaksTraits>(gcHandle(), mm::SpecialRefRegistry::instance()); gc::processWeaks<DefaultProcessWeaksTraits>(gcHandle(), mm::SpecialRefRegistry::instance());
@@ -94,6 +92,11 @@ void gc::mark::ConcurrentMark::runMainInSTW() {
} }
barriers::disableBarriers(); barriers::disableBarriers();
for (auto& thread : *lockedMutatorsList_) {
thread.gc().impl().gc().mark().markQueue().destroy();
}
endMarkingEpoch();
} }
void gc::mark::ConcurrentMark::runOnMutator(mm::ThreadData&) { void gc::mark::ConcurrentMark::runOnMutator(mm::ThreadData&) {