changeset 1217:019fd945ebc5

6834525: PIT: RowToleranceTransitivityTest test fail with crash on rhel4 x86 and rhel 5x86 Summary: do not try to use released XKB resources Reviewed-by: art
author yan
date Mon, 18 May 2009 12:39:58 +0400
parents f62f7fcc9965
children 875524a2b311
files src/solaris/classes/sun/awt/X11/XKeysym.java src/solaris/classes/sun/awt/X11/XToolkit.java src/solaris/classes/sun/awt/X11/keysym2ucs.h
diffstat 3 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/classes/sun/awt/X11/XKeysym.java	Fri May 15 15:40:35 2009 +0400
+++ b/src/solaris/classes/sun/awt/X11/XKeysym.java	Mon May 18 12:39:58 2009 +0400
@@ -29,6 +29,9 @@
 import java.util.Hashtable;
 import sun.misc.Unsafe;
 
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
 public class XKeysym {
 
     public static void main( String args[] ) {
@@ -67,6 +70,7 @@
     static Hashtable<Integer, Long> javaKeycode2KeysymHash = new Hashtable<Integer, Long>();
     static long keysym_lowercase = unsafe.allocateMemory(Native.getLongSize());
     static long keysym_uppercase = unsafe.allocateMemory(Native.getLongSize());
+    private static Logger keyEventLog = Logger.getLogger("sun.awt.X11.kye.XKeysym");
     public static char convertKeysym( long ks, int state ) {
 
         /* First check for Latin-1 characters (1:1 mapping) */
@@ -107,8 +111,15 @@
                 // clearly means that caller needs a so called primary keysym.
                 mods ^= XConstants.ShiftMask;
             }
-            XlibWrapper.XkbTranslateKeyCode(XToolkit.getXKBKbdDesc(), ev.get_keycode(),
+            long kbdDesc = XToolkit.getXKBKbdDesc();
+            if( kbdDesc != 0 ) {
+                XlibWrapper.XkbTranslateKeyCode(kbdDesc, ev.get_keycode(),
                        mods, XlibWrapper.iarg1, XlibWrapper.larg3);
+            }else{
+                // xkb resources already gone
+                keyEventLog.fine("Thread race: Toolkit shutdown before the end of a key event processing.");
+                return 0;
+            }
             //XXX unconsumed modifiers?
             return Native.getLong(XlibWrapper.larg3);
         } finally {
--- a/src/solaris/classes/sun/awt/X11/XToolkit.java	Fri May 15 15:40:35 2009 +0400
+++ b/src/solaris/classes/sun/awt/X11/XToolkit.java	Mon May 18 12:39:58 2009 +0400
@@ -2263,6 +2263,7 @@
         try {
             if (awt_UseXKB_Calls && awt_XKBDescPtr != 0) {
                 XlibWrapper.XkbFreeKeyboard(awt_XKBDescPtr, 0xFF, true);
+                awt_XKBDescPtr = 0;
             }
         } finally {
             awtUnlock();
--- a/src/solaris/classes/sun/awt/X11/keysym2ucs.h	Fri May 15 15:40:35 2009 +0400
+++ b/src/solaris/classes/sun/awt/X11/keysym2ucs.h	Mon May 18 12:39:58 2009 +0400
@@ -67,6 +67,9 @@
 tojava import java.util.Hashtable;
 tojava import sun.misc.Unsafe;
 tojava
+tojava import java.util.logging.Level;
+tojava import java.util.logging.Logger;
+tojava
 tojava public class XKeysym {
 tojava
 tojava     public static void main( String args[] ) {
@@ -105,6 +108,7 @@
 tojava     static Hashtable<Integer, Long> javaKeycode2KeysymHash = new Hashtable<Integer, Long>();
 tojava     static long keysym_lowercase = unsafe.allocateMemory(Native.getLongSize());
 tojava     static long keysym_uppercase = unsafe.allocateMemory(Native.getLongSize());
+tojava     private static Logger keyEventLog = Logger.getLogger("sun.awt.X11.kye.XKeysym");
 tojava     public static char convertKeysym( long ks, int state ) {
 tojava
 tojava         /* First check for Latin-1 characters (1:1 mapping) */
@@ -145,8 +149,15 @@
 tojava                 // clearly means that caller needs a so called primary keysym.
 tojava                 mods ^= XConstants.ShiftMask;
 tojava             }
-tojava             XlibWrapper.XkbTranslateKeyCode(XToolkit.getXKBKbdDesc(), ev.get_keycode(),
+tojava             long kbdDesc = XToolkit.getXKBKbdDesc();
+tojava             if( kbdDesc != 0 ) {
+tojava                 XlibWrapper.XkbTranslateKeyCode(kbdDesc, ev.get_keycode(),
 tojava                        mods, XlibWrapper.iarg1, XlibWrapper.larg3);
+tojava             }else{
+tojava                 // xkb resources already gone
+tojava                 keyEventLog.fine("Thread race: Toolkit shutdown before the end of a key event processing.");
+tojava                 return 0;
+tojava             }
 tojava             //XXX unconsumed modifiers?
 tojava             return Native.getLong(XlibWrapper.larg3);
 tojava         } finally {