Hi Artem,

On 09/23/2010 05:33 AM, Artem Ananiev wrote:
I'm not an i18n expert, just would like to understand the problem and
the fix.


Naoto Sato was kind enough to review the patch:
http://mail.openjdk.java.net/pipermail/i18n-dev/2010-September/000221.html

Could you provide the stack trace of the crash, please?


Sure. I am attaching the GtkJTextFieldTest.java (a reproducer) and the backtrace I obtained. Here are the steps I have to take to reproduce the crash:
1. Start an XIM server (I use ibus in gnome)
2. Run the reproducer and type something in one of the JTextFields
3. Restart the XIM server (for ibus, this requires right clicking on the icon in the system tray and selecting restart).
4. Switch back to the java program and try to type something again.

As I understand, the reason of calling getX11InputMethodData is that you
need to destroy "pX11IMData" and set the corresponding field in Java to
null, right?


Yeah. The code already checks (in getX11InputMethodData) if the XIM server has stopped. It can also automatically reconnect to the XIM server too. the problem is that if the XIM server is stopped and then restarted, X calls OpenXIMCallback which set XIMim to non null, skipping the check in getX11IMInputMethodData. Since pX11IMData does not correspond to the new X11im, the program crashes.

I posted an updated cr with comments clarifying the operation.
http://cr.openjdk.java.net/~omajid/webrevs/crash-on-xim-server-restart/webrev.01/

Cheers,
Omair


On 9/16/2010 11:58 PM, Omair Majid wrote:
Hi,

While looking at the bug filed at
https://bugzilla.redhat.com/show_bug.cgi?id=572147, I noticed that Java
applications crash if IBus (an X input server) is restarted.

The webrev is at
http://cr.openjdk.java.net/~omajid/webrevs/crash-on-xim-server-restart/webrev.00/



The code in awt_InputMethod.c guards against the XIM server going away,
but does not guard against it appearing again. When the XIM server is
restarted, the X server can send async requests to call OpenXIMCallback
in Java automatically:
(gdb) bt
#0 OpenXIMCallback (display=<value optimized out>,
client_data=<value optimized out>, call_data=<value optimized out>)
at ../../../src/solaris/native/sun/awt/awt_InputMethod.c:1464
#1 0x00000036b406dc4f in _XimFilterPropertyNotify
(display=0x7f503c0df300,
window=<value optimized out>, event=<value optimized out>,
client_data=<value optimized out>) at imInsClbk.c:126
#2 0x00007f4ff24f0f3f in Java_sun_awt_X11_XlibWrapper_XFilterEvent (
env=<value optimized out>, clazz=<value optimized out>,
ptr=<value optimized out>, window=<value optimized out>)
at ../../../src/solaris/native/sun/xawt/XlibWrapper.c:486
#3 0x00007f5039010f50 in ?? ()
#4 0x00007f5039005953 in ?? ()
#5 0x0000000000000000 in ?? ()

This causes the X11im pointer to get initialized and the checks in
getX11InputMethodData are escaped. The patch simply makes sure that the
checks are not escaped by calling getX11InputMethodData in
DestroyXIMCallback.

Any thoughts or comments?

Cheers,
Omair

(gdb) bt
#0  0x00000036b10329a5 in raise (sig=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00000036b1034185 in abort () at abort.c:92
#2  0x00007fb5e268c4b9 in os::abort (dump_core=true)
    at 
/usr/src/debug/icedtea6-1.8.1/openjdk/hotspot/src/os/linux/vm/os_linux.cpp:1481
#3  0x00007fb5e27a7da1 in VMError::report_and_die (this=0x7fb5911dc9e0)
    at 
/usr/src/debug/icedtea6-1.8.1/openjdk/hotspot/src/share/vm/utilities/vmError.cpp:868
#4  0x00007fb5e268fae3 in JVM_handle_linux_signal (sig=11, info=
    0x7fb5911dcbb0, ucVoid=0x7fb5911dca80, abort_if_unrecognized=-1860318880)
    at 
/usr/src/debug/icedtea6-1.8.1/openjdk/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp:494
#5  <signal handler called>
#6  0x00007fb544030600 in ?? ()
#7  0x00007fb5927cbb02 in Java_sun_awt_X11InputMethod_resetXIC (env=
    0x7fb5dc3611b8, this=<value optimized out>)
    at ../../../src/solaris/native/sun/awt/awt_InputMethod.c:1824
#8  0x00007fb5d9010f50 in ?? ()
#9  0x00007fb5911dcf80 in ?? ()
#10 0x00007fb5d9005953 in ?? ()
#11 0x00007fb5911dcf30 in ?? ()
#12 0x0000000000000000 in ?? ()

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;

public class GtkJTextFieldTest {
    public static void main(String[] args) throws Exception {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        final JTextField textField1 = new JTextField();
        textField1.setText("the quick brown fox jumps over the lazy dog");

        final JTextField textField2 = new JTextField();
        textField2.setText("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG");

        final JPanel panel = new JPanel();
        panel.setLayout(new BorderLayout());
        panel.setBorder(new EmptyBorder(10, 10, 10, 10));
        panel.add(textField1, BorderLayout.NORTH);
        panel.add(textField2, BorderLayout.SOUTH);

        final JFrame frame = new JFrame("Test");
        frame.add(panel);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }
}

Reply via email to