United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6668385 Java applet crashes IE 6 in AwtComponent::ImmAssociateContext()
JDK-6668385 : Java applet crashes IE 6 in AwtComponent::ImmAssociateContext()

Details
Type:
Bug
Submit Date:
2008-02-27
Status:
Closed
Updated Date:
2010-12-09
Project Name:
JDK
Resolved Date:
2009-03-23
Component:
client-libs
OS:
windows_xp
Sub-Component:
java.awt
CPU:
x86
Priority:
P2
Resolution:
Fixed
Affected Versions:
5.0u14,5.0u15,6u4
Fixed Versions:
5.0u18-rev (b04)

Related Reports
Backport:
Backport:
Backport:
Backport:
Relates:
Relates:

Sub Tasks

Description
Java applet crashes IE 6 (Windows XP SP2) when running on 1.5.0_14.
The problem is not reproducible on 1.5.0_13.

The problem is very well reproducible, although not strictly, both on
single and dual processor machines.

1. Test case
------------
Please run attached test case AHS.zip on 1.5.0_14:

- uncompress AHS.zip
- cd AHS
- open StartaAHS.html in IE
  1. click on the link to start AHS.
     a separate window will open. 
     it shows a single tab named "??rendeinfo"
  2. close windows after initiated
- Repeat steps 1+2 until IE will crash (10 - 15 iterations most likely are enough)


2. hs_err_pid.log
-----------------
Hotspot error log reproducibly shows a crash in [awt.dll+0xc86bc]:
(see attached hs_err_pid3576.log)

Stack: [0x051b0000,0x052b0000),  sp=0x052af9b4,  free space=1022k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [awt.dll+0xc86bc]
C  [USER32.dll+0x8709]
C  [USER32.dll+0x87eb]
C  [USER32.dll+0xb368]
C  [USER32.dll+0xb3b4]
C  [ntdll.dll+0xeae3]
C  [USER32.dll+0x93df]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  sun.awt.windows.WToolkit.eventLoop()V+0
j  sun.awt.windows.WToolkit.run()V+69
j  java.lang.Thread.run()V+11
v  ~StubRoutines::call_stub


3. awt function
---------------
[awt.dll+0xc86bc] translates into

0:000> ln awt+0xc86bc
(6d0c86b0)   awt!AwtComponent::ImmAssociateContext+0xc

                                    

Comments
WORK AROUND

use 1.5.0_13
                                     
2008-02-27
EVALUATION

The parent associated should be a component of an owned window last / currently active instead of the the last/current proxied.
                                     
2009-03-04
SUGGESTED FIX

------- awt_Component.cpp -------
*** /tmp/sccs.bIElO9	2009-02-05 12:04:03.000000000 +0300
--- awt_Component.cpp	2009-02-05 12:10:49.309350000 +0300
***************
*** 2167,2172 ****
--- 2167,2176 ----
  
          sm_focusedWindow = GetTopLevelParentForWindow(GetHWnd());
          ::SendMessage(hwnd, WM_SETFOCUS, (WPARAM)oldFocusOwner, 0);
+         
+         if (sm_focusOwner == hwnd) {
+             owner->SetLastProxiedFocusOwner(sm_focusOwner);
+         }
      }
  
      return TRUE;
***************
*** 4463,4470 ****
  
  HIMC AwtComponent::ImmAssociateContext(HIMC himc)
  {
!     HWND proxy = GetProxyFocusOwner();
!     return ::ImmAssociateContext((proxy != NULL) ? proxy : GetHWnd(), himc);
  }
  
  HWND AwtComponent::GetProxyFocusOwner()
--- 4467,4486 ----
  
  HIMC AwtComponent::ImmAssociateContext(HIMC himc)
  {
!     HWND proxy = (HWND)NULL;
!     AwtWindow * window = GetContainer();
! 
!     if (window != 0) {
! 	AwtFrame * owner = window->GetOwningFrameOrDialog();
! 	if (owner != 0) {
! 	    proxy = owner->GetLastProxiedFocusOwner();
! 	}
!     }else{
!         return 0;
!     }    
!     
!     HIMC myhimc = ::ImmAssociateContext((proxy != NULL) ? proxy : GetHWnd(), himc);
!     return myhimc;
  }
  
  HWND AwtComponent::GetProxyFocusOwner()

------- awt_Frame.h -------
*** /tmp/sccs.NcuHXZ	2009-02-05 12:04:03.000000000 +0300
--- awt_Frame.h	2008-11-12 14:40:28.414340000 +0300
***************
*** 98,103 ****
--- 98,106 ----
  	return m_proxyFocusOwner;
      }
  
+     INLINE HWND GetLastProxiedFocusOwner() { return m_lastProxiedFocusOwner; }
+     INLINE void SetLastProxiedFocusOwner(HWND hwnd) { m_lastProxiedFocusOwner = hwnd; }
+ 
      void SetMaximizedBounds(int x, int y, int w, int h);
      void ClearMaximizedBounds();
  
***************
*** 159,164 ****
--- 162,171 ----
         or an AwtDialog (or one of its children) has the logical input focus. */
      HWND m_proxyFocusOwner;
  
+     /* Retains the last/current sm_focusOwner proxied. Actually, it should be
+      * a component of an owned window last/currently active. */
+     HWND m_lastProxiedFocusOwner;
+ 
      /* 
       * Fix for 4823903.
       * Retains a focus proxied window to set the focus correctly

------- awt_Frame.cpp -------
*** /tmp/sccs.9TvZbQ	2009-02-05 12:04:03.000000000 +0300
--- awt_Frame.cpp	2008-11-12 14:46:04.163862000 +0300
***************
*** 83,88 ****
--- 83,89 ----
      m_windowClassName = NULL;
      m_isUndecorated = FALSE;
      m_proxyFocusOwner = NULL;
+     m_lastProxiedFocusOwner = NULL;
      m_actualFocusedWindow = NULL;
      m_iconic = FALSE;
      m_zoomed = FALSE;
***************
*** 334,340 ****
  	case WM_IME_KEYUP:
  	case WM_INPUTLANGCHANGEREQUEST:
  	case WM_INPUTLANGCHANGE:
! 	    AwtComponent *p = AwtComponent::GetComponent(sm_focusOwner);
  	    if  (p!= NULL) {
  		return p->WindowProc(message, wParam, lParam);
  	    }
--- 335,341 ----
  	case WM_IME_KEYUP:
  	case WM_INPUTLANGCHANGEREQUEST:
  	case WM_INPUTLANGCHANGE:
! 	    AwtComponent *p = AwtComponent::GetComponent(parent->GetLastProxiedFocusOwner());
  	    if  (p!= NULL) {
  		return p->WindowProc(message, wParam, lParam);
  	    }
                                     
2009-03-04



Hardware and Software, Engineered to Work Together