diff options
author | Yi Kong <yikong@google.com> | 2018-01-09 16:55:04 -0800 |
---|---|---|
committer | Yi Kong <yikong@google.com> | 2018-01-09 19:44:44 -0800 |
commit | e11d50f23dc1256ad933d209f2db8f58138f02c0 (patch) | |
tree | 9a02321fc6b464be78086d1cb966c0b000d3f1bc | |
parent | ea443af9fd561ee3c3649ec98cafe8ecda077371 (diff) |
Workaround bogus Thread Safety Analysis warning
Building art/runtime/gc/heap.cc with thread safety analysis produces
warnings that mutator_lock_->AssertNotHeld() conflicts with
ScopedObjectAccess for holding shared and exclusive lock within the same
scope. AssertNotHeld() is a capability assertion and does not actually
hold the lock.
Thread safety analysis was broken thus the warning not appearing before
Clang r316199 update. Temporarily workaround the issue while we fix the
bug in upstream.
Bug: 71769596
Test: m checkbuild
Change-Id: I48234db966332cf24e40774cd62589359aab6d05
-rw-r--r-- | adbconnection/adbconnection.cc | 5 | ||||
-rw-r--r-- | runtime/gc/heap.cc | 15 |
2 files changed, 16 insertions, 4 deletions
diff --git a/adbconnection/adbconnection.cc b/adbconnection/adbconnection.cc index a5c885a933..127792f6b4 100644 --- a/adbconnection/adbconnection.cc +++ b/adbconnection/adbconnection.cc @@ -484,7 +484,10 @@ bool AdbConnectionState::SetupAdbConnection() { void AdbConnectionState::RunPollLoop(art::Thread* self) { CHECK_EQ(self->GetState(), art::kNative); - art::Locks::mutator_lock_->AssertNotHeld(self); + // TODO: Clang prebuilt for r316199 produces bogus thread safety analysis warning for holding both + // exclusive and shared lock in the same scope. Remove the assertion as a temporary workaround. + // http://b/71769596 + // art::Locks::mutator_lock_->AssertNotHeld(self); self->SetState(art::kWaitingInMainDebuggerLoop); // shutting_down_ set by StopDebuggerThreads while (!shutting_down_) { diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 9edba96ddd..f0f8b4e593 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -1900,7 +1900,10 @@ HomogeneousSpaceCompactResult Heap::PerformHomogeneousSpaceCompact() { count_requested_homogeneous_space_compaction_++; // Store performed homogeneous space compaction at a new request arrival. ScopedThreadStateChange tsc(self, kWaitingPerformingGc); - Locks::mutator_lock_->AssertNotHeld(self); + // TODO: Clang prebuilt for r316199 produces bogus thread safety analysis warning for holding both + // exclusive and shared lock in the same scope. Remove the assertion as a temporary workaround. + // http://b/71769596 + // Locks::mutator_lock_->AssertNotHeld(self); { ScopedThreadStateChange tsc2(self, kWaitingForGcToComplete); MutexLock mu(self, *gc_complete_lock_); @@ -1978,7 +1981,10 @@ void Heap::TransitionCollector(CollectorType collector_type) { Runtime* const runtime = Runtime::Current(); Thread* const self = Thread::Current(); ScopedThreadStateChange tsc(self, kWaitingPerformingGc); - Locks::mutator_lock_->AssertNotHeld(self); + // TODO: Clang prebuilt for r316199 produces bogus thread safety analysis warning for holding both + // exclusive and shared lock in the same scope. Remove the assertion as a temporary workaround. + // http://b/71769596 + // Locks::mutator_lock_->AssertNotHeld(self); // Busy wait until we can GC (StartGC can fail if we have a non-zero // compacting_gc_disable_count_, this should rarely occurs). for (;;) { @@ -2521,7 +2527,10 @@ collector::GcType Heap::CollectGarbageInternal(collector::GcType gc_type, } } ScopedThreadStateChange tsc(self, kWaitingPerformingGc); - Locks::mutator_lock_->AssertNotHeld(self); + // TODO: Clang prebuilt for r316199 produces bogus thread safety analysis warning for holding both + // exclusive and shared lock in the same scope. Remove the assertion as a temporary workaround. + // http://b/71769596 + // Locks::mutator_lock_->AssertNotHeld(self); if (self->IsHandlingStackOverflow()) { // If we are throwing a stack overflow error we probably don't have enough remaining stack // space to run the GC. |