Correct potential deadlock in AnrTimerService
This change eliminates a potential deadlock that would occur if an ANR timer expires but the upper Java layer has lost track of the timer. (The mechanism by which the upper layer loses track of the timer is not understood.) If the upper layer cannot handle the timer expiration, the native layer cleans up its records. That clean-up was locking a mutex and then calling AnrTimerService::discard, which takes the mutex again. Mutexes are non-recursive and this is a deadlock. The fix removes the extraneous lock. A dangling comment is also cleaned up. Tested with a custom build that triggered the deadlock condition. The baseline code generated an ANR report that matches the reports in the bug. The modified code did not generate an ANR and proceeded normally. Flag: EXEMPT bugfix Bug: 357341347 Test: atest * FrameworksServicesTests:AnrTimerTest * FrameworksServicesTests:com.android.server.am * FrameworksMockingServicesTests:com.android.server.am Change-Id: I12aeef5905409dc6c062e1fbd23a000cf0c9515c
Loading
Please register or sign in to comment