Note: There are a few cases of duplicates in user autocompletion which are being worked on.

nsWebShellWindow destructor prevents nsXULWindow destructor from clearing pointers from tree owners

RESOLVED FIXED in mozilla17

Status

()

Core
General
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: neil@parkwaycc.co.uk, Assigned: Justin Lebar (not reading bugmail))

Tracking

Trunk
mozilla17
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 1 obsolete attachment)

(Reporter)

Description

5 years ago
For some reason, nsWebShellWindow's destructor clears out the nsIWidget member inherited from nsXULWindow, accidentally bypassing nsXULWindow's destruction code. Previously someone has always managed to invoke Destroy manually, however as of bug 777063 it's definitely possible to tickle the code so that nsWebShellWindow gets destroyed before Destroy gets invoked. This prevents nsXULWindow from clearing the pointers in the tree owners which are now stale and promptly crash if any of the tree owner's methods get called.

As it happens, Destroy has an identical copy of the code to clear that member.
(Reporter)

Comment 1

5 years ago
I meant bug 775676 of course...
Depends on: 775676
No longer depends on: 777063
(Reporter)

Comment 2

5 years ago
Created attachment 646761 [details] [diff] [review]
Proposed patch
Assignee: nobody → neil
Status: NEW → ASSIGNED
Attachment #646761 - Flags: review?(roc)
(Assignee)

Comment 3

5 years ago
Created attachment 646769 [details] [diff] [review]
Patch, v1
Attachment #646769 - Flags: review?(roc)
Attachment #646769 - Flags: review?(roc) → review+
Attachment #646761 - Attachment is obsolete: true
Attachment #646761 - Flags: review?(roc)
(Reporter)

Updated

5 years ago
Assignee: neil → justin.lebar+bug
(Assignee)

Comment 4

5 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/20b67f48676c
Sorry, I backed this out on inbound because it looks like it introduced a perma-orange in make check on Windows debug builds:
https://hg.mozilla.org/integration/mozilla-inbound/rev/72966f49cf09

https://tbpl.mozilla.org/php/getParsedLog.php?id=13975366&tree=Mozilla-Inbound

mozilla::ShutdownXPCOM[xul +0x1253D82]
ScopedXPCOM::~ScopedXPCOM[TestAppShellSteadyState +0x37E0]
main[TestAppShellSteadyState +0x5970]
__tmainCRTStartup[TestAppShellSteadyState +0x97EF]
mainCRTStartup[TestAppShellSteadyState +0x961F]
BaseThreadInitThunk[kernel32 +0x133CA]
RtlInitializeExceptionChain[ntdll +0x39ED2]
RtlInitializeExceptionChain[ntdll +0x39EA5]

###!!! 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)
(Reporter)

Comment 6

5 years ago
Annoying. The test shuts down XPCOM while the window is still open, causing the window mediator to unregister all of its windows. Because it's the owner of last resort, this causes the destructor to run, which (with this patch) causes the nsXULWindow to try to unregister itself again.
(Assignee)

Comment 7

5 years ago
Sounds like we should make sure we don't re-enter nsXULWindow::Destroy.
(Assignee)

Comment 8

5 years ago
https://tbpl.mozilla.org/?tree=Try&rev=3cd2a329942b
(Reporter)

Comment 9

5 years ago
(In reply to Justin Lebar from comment #7)
> Sounds like we should make sure we don't re-enter nsXULWindow::Destroy.
We don't, this is the only call to nsXULWindow::Destroy in the test.
(Assignee)

Comment 10

5 years ago
Okay, let's try this.  https://tbpl.mozilla.org/?tree=Try&rev=120d646c3cf3
(Assignee)

Comment 11

5 years ago
Created attachment 648005 [details] [diff] [review]
Part 1a, v1: Release the references after we release the lock.

As Neil pointed out on IRC, we don't actually need this additional block scope, so long as the array is declared before the auto-lock.  I think it clarifies things, but I'm not attached to it.
Attachment #648005 - Flags: review?(roc)
Attachment #648005 - Flags: review?(roc) → review+
(Assignee)

Comment 12

5 years ago
Comment on attachment 648005 [details] [diff] [review]
Part 1a, v1: Release the references after we release the lock.

https://hg.mozilla.org/integration/mozilla-inbound/rev/3111cd3bc5f5
https://hg.mozilla.org/mozilla-central/rev/3111cd3bc5f5
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla17
You need to log in before you can comment on or make changes to this bug.