The default bug view has changed. See this FAQ.

"ASSERTION: ImmAssociateContextEx failed to restore default IMC"

RESOLVED FIXED in mozilla9

Status

()

Core
Widget: Win32
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: Jesse Ruderman, Assigned: bbondy)

Tracking

(Blocks: 1 bug, {testcase})

Trunk
mozilla9
x86_64
Windows 7
testcase
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
1. In the address bar, enter http://www.squarefree.com/bug662261/x.test
2. Right-click Firefox's taskbar icon and select "close all windows"

Result:

###!!! ASSERTION: ImmAssociateContextEx failed to restore default IMC: 'ret || !nsIMM32Handler::IsIMEAvailable()', file widget/src/windows/nsWindow.cpp, line 8038
(Assignee)

Comment 1

6 years ago
I can reproduce this so I'll take it.
(Assignee)

Updated

6 years ago
Assignee: nobody → netzen
(Assignee)

Comment 2

6 years ago
Created attachment 546938 [details] [diff] [review]
Patch for ASSERTION: ImmAssociateContextEx failed to restore default IMC

The assertion was failing because of a GetLastError() of invalid handle on the Win32 API call to "::ImmAssociateContextEx(mWnd, .._)".
The problem was that we were destroying the window twice.

The call "DispatchStandardEvent(NS_DESTROY);" inside "nsWindow::OnDestroy" was sometimes leading to "nsXULWindow::Destroy" which would in turn call "mWindow->Destroy()" a second time. Where the error happened.
  
We were already checking to make sure we didn't destroy twice with "if (nsnull == mWnd) return NS_OK" in "nsWindow::Destroy()" but this would only check that we finished the WM_DESTROY message, not that we already started the WM_DESTROY message.  

Instead we should check that we have started the WM_DESTROY message to ensure the above situation doens't happen.  This can be done by changing: "if (nsnull == mWnd) return NS_OK" to " if (mOnDestroyCalled)
 return NS_OK;"
Attachment #546938 - Flags: review?(neil)
(Assignee)

Comment 3

6 years ago
This patch also fixes a different similar error in Bug 622312.
(Reporter)

Updated

6 years ago
Blocks: 622312

Comment 4

6 years ago
Aha, so OnDestroy calls DispatchStandardEvent(NS_DESTROY) which normally does nothing, because something else has been destroyed first. But sometimes it hasn't, in which case nsXULWindow tries to destroy the nsWindow again...
(Assignee)

Comment 5

6 years ago
Right, basically from within the destroy it can lead to another destroy.  We had a check for double destroy but the way we checked it was if the destroy was done, and not if the destroy had already started.

Updated

6 years ago
Attachment #546938 - Flags: review?(neil) → review+
(Assignee)

Updated

6 years ago
Attachment #546938 - Flags: checkin?
(Assignee)

Comment 6

6 years ago
Comment on attachment 546938 [details] [diff] [review]
Patch for ASSERTION: ImmAssociateContextEx failed to restore default IMC

Going to run through try before checkin?
Attachment #546938 - Flags: checkin?
(Assignee)

Comment 7

6 years ago
pushed to mozilla-inbound.
http://hg.mozilla.org/mozilla-central/rev/72459db22a34
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla9
You need to log in before you can comment on or make changes to this bug.