summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/trace.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/runtime/trace.cc b/runtime/trace.cc
index bdc6757c89..d97dcb5a3d 100644
--- a/runtime/trace.cc
+++ b/runtime/trace.cc
@@ -303,6 +303,12 @@ void* Trace::RunSamplingThread(void* arg) {
}
}
{
+ // Avoid a deadlock between a thread doing garbage collection
+ // and the profile sampling thread, by blocking GC when sampling
+ // thread stacks (see b/73624630).
+ gc::ScopedGCCriticalSection gcs(self,
+ art::gc::kGcCauseInstrumentation,
+ art::gc::kCollectorTypeInstrumentation);
ScopedSuspendAll ssa(__FUNCTION__);
MutexLock mu(self, *Locks::thread_list_lock_);
runtime->GetThreadList()->ForEach(GetSample, the_trace);