Fix allocation tracking race
Need to instrument the stubs before calling
Heap::SetAlloctrackingEnabled or else we can get this DCHECK failing
DCHECK(!IsAllocTrackingEnabled())
Change-Id: I1fb5df217a2785baf22b4f57887cd323f13f0973
diff --git a/runtime/gc/allocation_record.cc b/runtime/gc/allocation_record.cc
index 83e5bad..4de5388 100644
--- a/runtime/gc/allocation_record.cc
+++ b/runtime/gc/allocation_record.cc
@@ -238,9 +238,12 @@
<< records->max_stack_depth_ << " frames, taking up to "
<< PrettySize(sz * records->alloc_record_max_) << ")";
heap->SetAllocationRecords(records);
- heap->SetAllocTrackingEnabled(true);
}
Runtime::Current()->GetInstrumentation()->InstrumentQuickAllocEntryPoints();
+ {
+ MutexLock mu(self, *Locks::alloc_tracker_lock_);
+ heap->SetAllocTrackingEnabled(true);
+ }
} else {
{
MutexLock mu(self, *Locks::alloc_tracker_lock_);