Closed Bug 1237690 Opened 5 years ago Closed 5 years ago

Deadlock in nsAppShell::SyncRunEvent

Categories

(Core :: Widget: Android, defect)

All
Android
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla46
Tracking Status
firefox46 --- fixed

People

(Reporter: jchen, Assigned: jchen)

References

Details

(Keywords: regression)

Attachments

(1 file)

Bug 1233812 introduced a possible deadlock in nsAppShell::SyncRunEvent. When we're waiting on the event in the source thread, we're holding onto sAppShellLock, but that prevents another thread from taking that lock. If that other thread is the Gecko thread, there will be a deadlock, because the event never gets run so sAppShellLock never gets released.
In order to prevent the deadlock, we need to release sAppShellLock when
we start waiting in SyncRunEvent. However, we cannot simply unlock it
before the wait because that introduces an out-of-order unlocking wrt
mSyncRunMonitor, which can cause further deadlocks. So this patch
converts mSyncRunMoitor to a condvar and make it use sAppShellLock. That
then involves making aAppShellLock a Mutex instead of a StaticMutex. The
final result is having one lock (sAppShellLock), which supports any
other condvars that we have, such as mSyncRunFinished.
Attachment #8705268 - Flags: review?(snorp)
Attachment #8705268 - Flags: review?(snorp) → review+
https://hg.mozilla.org/mozilla-central/rev/27df2a73ac7d
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla46
Version: unspecified → Trunk
You need to log in before you can comment on or make changes to this bug.