Open Bug 873589 Opened 12 years ago Updated 3 years ago

Firefox deadlocks if nsWindowMediatorListener tries to enumerate windows

Categories

(Core :: Widget, defect, P3)

defect

Tracking

()

People

(Reporter: jimb, Unassigned)

Details

It's easy to make the MutexAutoLock in nsWindowMediator::UnregisterWindow deadlock with the MutexAutoLock in nsWindowMediator::GetEnumerator. - Open up two top-level windows. - Evaluate the following in a chrome-privileged scratchpad: let l = {} l.onOpenWindow = l.onWindowTitleChange = () => {}; l.onCloseWindow = (aWindow) => { Services.wm.getEnumerator("navigator:browser"); }; Services.wm.addListener(l); Firefox becomes flustered and hangs, saying: ###!!! ERROR: Potential deadlock detected: === Cyclical dependency starts at --- Mutex : nsWindowMediator.mListLock (currently acquired) calling context [stack trace unavailable] === Cycle completed at --- Mutex : nsWindowMediator.mListLock (currently acquired) calling context [stack trace unavailable] ###!!! Deadlock may happen NOW! ###!!! ASSERTION: Potential deadlock detected: Cyclical dependency starts at Mutex : nsWindowMediator.mListLock (currently acquired) Cycle completed at Mutex : nsWindowMediator.mListLock (currently acquired) ###!!! Deadlock may happen NOW! : 'Error', file /home/jimb/moz/dbg/obj-bug/xpcom/build/BlockingResourceBase.cpp, line 128 Is this list really even used by multiple threads at all? Could we remove the lock? (Is the mediator's enumerator and list management written carefully enough to permit this kind of re-entrant use at all?)
I cannot imagine that it is actually threadsafe, but you should add some runtime aborts if you want to try removing the lock, so that failures show up both on tinderbox and in the wild.
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.