Dump DisplayModeDirector state without locking mSyncRoot

The current locking order of DisplayManagerGlobal.mLock,
DisplayManagerService.mSyncRoot and SensorObserver.mSensorObserverLock
may cause a deadlock when an EVENT_DISPLAY_CHANGED event is handled
by MediaRouter.Static and DMD.SensorObserver at the same time as
a DisplayManagerService dump is in progress.

The locking order of onDisplayChanged is:
   - mSensorObserverLock -> DMG.mLock -> DMS.mSyncRoot
The locking order of DMS.dumpInternal is:
   - DMS.mSyncRoot -> mSensorOberverLock

This change removes the mSyncRoot locking during the DMD dump to keep
the lock ordering from going in a cycle. DMD already guards its state
during a dump with its own class lock, so holding mSyncRoot is not
really necessary.

Bug: 202515175
Test: builds
Change-Id: I464e570e7107b49633e599b25ef1d208c9fc76aa
This commit is contained in:
jorgegil@google.com
2021-10-13 14:20:14 -07:00
parent f23eb51da9
commit 6e11e049e9

View File

@@ -2062,9 +2062,6 @@ public final class DisplayManagerService extends SystemService {
pw.println();
mLogicalDisplayMapper.dumpLocked(pw);
pw.println();
mDisplayModeDirector.dump(pw);
final int callbackCount = mCallbacks.size();
pw.println();
pw.println("Callbacks: size=" + callbackCount);
@@ -2087,6 +2084,8 @@ public final class DisplayManagerService extends SystemService {
pw.println();
mPersistentDataStore.dump(pw);
}
pw.println();
mDisplayModeDirector.dump(pw);
}
private static float[] getFloatArray(TypedArray array) {