JDK-6193715 : Regression: AWT/NonFocusableTest and AWT/bat crashed Virtual Machine on Windows platforms
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_2003,windows_xp
  • CPU: generic,x86
  • Submitted: 2004-11-11
  • Updated: 2015-11-25
  • Resolved: 2005-02-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b15Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
System Config.
Mustang B10 and B11, Windows XP Pro, Windows 2000, Windows XP (AMD), Windows 98 
Symptom:
     AWT test (merlin/awt/Automated/MerlinFocus/Mw/NonFocusableTest/NonFocusableTest.html) 
and
(merlin/awt/Automated/bat)
were run on the above Windows platforms and failed.

The same test was tried on tiger update 1 b04, mustang b09 and it was OK.
Starting from mustang b10, it failed.

Testcase Info.:
This test is to set a FocusOwner non focusable and to check whether 
the Focus has been transferred programmatically
1)When the current focusowner is disabled,setvisible(false),removed
  then Forward focustraversal must occur automatically.
2)When the current focusowner is disbled/remove/setvisible(false)
  and there is no component to get focus then the global
  focus owner should be cleared.

Here are the test messages from NonFocusableTest.tlog:
An unexpected error has been detected by HotSpot Virtual Machine:
##
##  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00c432d8, pid=-294093, tid=4
294581875
##
## Java VM: Java HotSpot(TM) Client VM (1.6.0-ea-b10 mixed mode)
## Problematic frame:
## v  ~BufferBlob::jni_fast_GetLongField
##
## An error report file with more information is saved as hs_err_pid4294673203.l
og
==============================================================================
princess2% more hs_err_pid4294673203.log
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00c432d8, pid=-294093, tid=42
94581875
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0-ea-b10 mixed mode)
# Problematic frame:
# v  ~BufferBlob::jni_fast_GetLongField
#

---------------  T H R E A D  ---------------

Current thread (0x006c5680):  JavaThread "AWT-EventQueue-0" [_thread_in_native, 
id=-385421]

siginfo: ExceptionCode=0xc0000005, reading address 0xffffffff

Registers:
EAX=0x0b4dfa7c, EBX=0x00000042, ECX=0x0000000c, EDX=0x00000000
ESP=0x0b4dfa18, EBP=0x0b4dfa50, ESI=0x00000042, EDI=0x006c5734
EIP=0x00c432d8, EFLAGS=0x00010246

Top of Stack: (sp=0x0b4dfa18)
0x0b4dfa18:   006ab030 6d795055 006c5734 00000000
0x0b4dfa28:   00000042 006c5734 006ab030 00000042
0x0b4dfa38:   0b4dfa2c 0b4df848 0b4dfa7c 6d7db9ea
0x0b4dfa48:   6d7e5c68 00000000 0b4dfa88 6d149b31
0x0b4dfa58:   006c5734 00000000 00000042 006c5680
0x0b4dfa68:   0705a3e0 0705a3e0 6d149bfc 00000000
0x0b4dfa78:   0b4dfa64 0b4dfdc8 6d173958 00000000
0x0b4dfa88:   0b4dfac8 00bd829d 006c5734 0b4dfae4 

Instructions: (pc=0x00c432d8)
0x00c432c8:   c1 01 0f 85 24 00 00 00 8b 54 24 0c 8b 74 24 10
0x00c432d8:   8b 12 c1 ee 02 8b 04 32 8b 54 32 04 3b 0d b0 72 


Stack: [0x0b490000,0x0b4f0000),  sp=0x0b4dfa18,  free space=318k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
v  ~BufferBlob::jni_fast_GetLongField
C  [AWT.DLL+0xd9b31]
j  sun.awt.windows.WGlobalCursorManager.setCursor(Ljava/awt/Component;Ljava/awt/
Cursor;Z)V+0
j  sun.awt.GlobalCursorManager._updateCursor(Z)V+137
j  sun.awt.GlobalCursorManager.access$000(Lsun/awt/GlobalCursorManager;Z)V+2
j  sun.awt.GlobalCursorManager$NativeUpdater.run()V+39
j  java.awt.event.InvocationEvent.dispatch()V+47
j  java.awt.EventQueue.dispatchEvent(Ljava/awt/AWTEvent;)V+26
j  java.awt.EventDispatchThread.pumpOneEventForHierarchy(ILjava/awt/Component;)Z
+200
j  java.awt.EventDispatchThread.pumpEventsForHierarchy(ILjava/awt/Conditional;Lj
ava/awt/Component;)V+26
j  java.awt.EventDispatchThread.pumpEvents(ILjava/awt/Conditional;)V+4
j  java.awt.EventDispatchThread.pumpEvents(Ljava/awt/Conditional;)V+3
j  java.awt.EventDispatchThread.run()V+9


Attached test program (NonFocusableTest.java) for reference.
###@###.### 2004-11-11 00:04:59 GMT

Additional Info.:
merlin/awt/Automated/bat also failed with the same error.
attached test program (AWTBAT.java) as well.

###@###.### 2004-11-11 19:41:14 GMT

Comments
SUGGESTED FIX this is a manuall "diff" - the real diff looks very ugly and hard to understand. ------- new awt_Cursor.cpp ------- struct GlobalSetCursorStruct { jobject cursor; jboolean u; }; static void GlobalSetCursor(void* pStruct) { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); jobject cursor = ((GlobalSetCursorStruct*)pStruct)->cursor; jboolean u = ((GlobalSetCursorStruct*)pStruct)->u; jlong pData = env->GetLongField(cursor, AwtCursor::pDataID); AwtCursor *awtCursor = (AwtCursor *)jlong_to_ptr(pData); if (awtCursor == NULL) { awtCursor = AwtCursor::CreateSystemCursor(cursor); } HCURSOR hCursor = awtCursor->GetHCursor(); if (jobject jcomp = AwtComponent::FindHeavyweightUnderCursor(u)) { if(jobject jpeer = AwtObject::GetPeerForTarget(env, jcomp)) { if(AwtComponent *awtComponent = (AwtComponent*)JNI_GET_PDATA(jpeer)) { awtComponent->setCursorCache(hCursor); } } } if( TRUE == awtCursor->IsCustomCursor() ) { AwtToolkit::GetInstance().NotifyCustomCursor(); } ::SetCursor(hCursor); // don't need WM_AWT_SETCURSOR if( FALSE == awtCursor->IsCustomCursor() ) { AwtToolkit::GetInstance().NotifySystemCursor(); } env->DeleteGlobalRef(((GlobalSetCursorStruct*)pStruct)->cursor); } /* * Class: sun_awt_windows_WGlobalCursorManager * Method: setCursor * Signature: (Ljava/awt/Component;Ljava/awt/Cursor;)V */ JNIEXPORT void JNICALL Java_sun_awt_windows_WGlobalCursorManager_setCursor(JNIEnv *env, jobject, jobject, jobject cursor, jboolean u) { TRY; if (cursor != NULL) { // fix for 4430302 - getCursor() returns NULL GlobalSetCursorStruct data; data.cursor = env->NewGlobalRef(cursor); data.u = u; AwtToolkit::GetInstance().InvokeFunction( GlobalSetCursor, (void *)&data); } else { JNU_ThrowNullPointerException(env, "NullPointerException"); } CATCH_BAD_ALLOC; } ------- old awt_Cursor.cpp ------- /* * Class: sun_awt_windows_WGlobalCursorManager * Method: setCursor * Signature: (Ljava/awt/Component;Ljava/awt/Cursor;)V */ JNIEXPORT void JNICALL Java_sun_awt_windows_WGlobalCursorManager_setCursor(JNIEnv *env, jobject, jobject, jobject cursor, jboolean u) { TRY; if (cursor != NULL) { // fix for 4430302 - getCursor() returns NULL jlong pData = env->GetLongField(cursor, AwtCursor::pDataID); AwtCursor *awtCursor = (AwtCursor *)jlong_to_ptr(pData); if (awtCursor == NULL) { awtCursor = AwtCursor::CreateSystemCursor(cursor); } HCURSOR hCursor = awtCursor->GetHCursor(); jobject jcomp = AwtComponent::FindHeavyweightUnderCursor(u); if (jcomp!=NULL) { AwtComponent *awtComponent = (AwtComponent*)JNI_GET_PDATA(AwtObject::GetPeerForTarget(env, jcomp)); if (awtComponent) { awtComponent->setCursorCache(hCursor); } } if( TRUE == awtCursor->IsCustomCursor() ) { AwtToolkit::GetInstance().NotifyCustomCursor(); } AwtToolkit::GetInstance().SendMessage(WM_AWT_SETCURSOR, (WPARAM)hCursor); if( FALSE == awtCursor->IsCustomCursor() ) { AwtToolkit::GetInstance().NotifySystemCursor(); } } else { JNU_ThrowNullPointerException(env, "NullPointerException"); } CATCH_BAD_ALLOC; } ###@###.### 2004-11-17 17:52:14 GMT
17-11-2004

EVALUATION Seems to be caused by fix for 5097531. Could not reproduce with b11 on XP. ###@###.### 2004-11-11 19:29:57 GMT Reproduced on XP. Null check missing in 5097531 fix. Also, the code in question should be moved to toolkit thread for safety. ###@###.### 2004-11-17 17:52:14 GMT
11-11-2004