Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 1751 by [email protected]: Extremely fast X input is reordered/dropped/causes a hang
https://code.google.com/p/ibus/issues/detail?id=1751

What version of the product are you using? On what operating system?
OS (Linux distributions, UNIX or ...): Linux (Ubuntu 14.04)
Architecture (i386, x86_64): x86_64
IBus version: Ibus 1.5.5
Input method name and version: X11 2:1.6.2-1ubuntu2
Python version: 2.7.6
dbus version: 1.6.18
dbus-python version: 1.2.0-2build2

What steps will reproduce the problem?
1. Use the XMonad window manager (default configuration works. It's very odd but on my machine I can't get the race to trigger unless I'm using this Window manager)
2. Make sure IBUS is enabled (e.g., echo $XMODIFIERS outputs @im=ibus)
3. Open rxvt-unicode
4. Run this Python test script (after starting the script, press a key while focused on the terminal window):

from Xlib import X, XK, display
from Xlib.ext import record, xtest
from Xlib.protocol import rq, event
from Xlib.xobject import drawable
import time

display = display.Display()
screen = display.screen()
w = display.get_input_focus().focus
assert isinstance(w, drawable.Window)

events = [
            (38,X.KeyPress),
            (38,X.KeyRelease),
            (39,X.KeyPress),
            (39,X.KeyRelease),
            (38,X.KeyPress),
            (38,X.KeyRelease),
            (39,X.KeyPress),
            (39,X.KeyRelease),
            (38,X.KeyPress),
            (38,X.KeyRelease),
            (39,X.KeyPress),
            (39,X.KeyRelease),
            (38,X.KeyPress),
            (38,X.KeyRelease),
            (39,X.KeyPress),
            (39,X.KeyRelease),
            (38,X.KeyPress),
            (38,X.KeyRelease),
            (39,X.KeyPress),
            (39,X.KeyRelease),
            (38,X.KeyPress),
            (38,X.KeyRelease),
            (39,X.KeyPress),
            (39,X.KeyRelease),
            (38,X.KeyPress),
            (38,X.KeyRelease),
            (39,X.KeyPress),
            (39,X.KeyRelease),
            (38,X.KeyPress),
            (38,X.KeyRelease),
            (39,X.KeyPress),
            (39,X.KeyRelease),
            (38,X.KeyPress),
            (38,X.KeyRelease),
            (39,X.KeyPress),
            (39,X.KeyRelease),
            (38,X.KeyPress),
            (38,X.KeyRelease),
            (39,X.KeyPress),
            (39,X.KeyRelease),
            (38,X.KeyPress),
            (38,X.KeyRelease),
            (39,X.KeyPress),
            (39,X.KeyRelease),
            (38,X.KeyPress),
            (38,X.KeyRelease),
            (39,X.KeyPress),
            (39,X.KeyRelease),
            (38,X.KeyPress),
            (38,X.KeyRelease),
            (39,X.KeyPress),
            (39,X.KeyRelease)
         ]

w.grab_keyboard(False, X.GrabModeAsync, X.GrabModeAsync, X.CurrentTime)
while True:
    e = display.next_event()
    if (e.type == X.KeyPress):
        display.ungrab_keyboard(X.CurrentTime)
        for keycode, event_type in events:
            xtest.fake_input(w, event_type, keycode)
        display.sync()
        break

What is the expected output? What do you see instead?
We expect asasasasasa.... output to the terminal.

The actual result is that the letters are sometimes reordered, and rxvt-unicode will usually hang. It's stuck waiting on the input method:

(gdb) bt
#0 0x00007ffff6452c50 in __poll_nocancel () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007ffff5a6cb72 in ?? () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
#2 0x00007ffff5a6e64f in xcb_wait_for_event () from /usr/lib/x86_64-linux-gnu/libxcb.so.1 #3 0x00007ffff7180198 in _XReadEvents (dpy=dpy@entry=0x778b70) at ../../src/xcb_io.c:401 #4 0x00007ffff7168751 in XIfEvent (dpy=0x778b70, event=event@entry=0x7fffffffc4b0, predicate=predicate@entry=0x7ffff71ae790 <_CheckCMEvent>, arg=arg@entry=0x7d49c0
"\200eG\367\377\177") at ../../src/IfEvent.c:68
#5 0x00007ffff71aef24 in _XimXRead (im=0x7d49c0, recv_buf=0x7fffffffd0e0 "", buf_len=2048,
ret_len=0x7fffffffc5dc) at ../../../../modules/im/ximcp/imTrX.c:476
#6 0x00007ffff71afb80 in _XimReadData (im=im@entry=0x7d49c0, len=len@entry=0x7fffffffc63e,
buf=buf@entry=0x7fffffffd0e0 "", buf_size=buf_size@entry=2048) at
../../../../modules/im/ximcp/imTransR.c:165
#7 0x00007ffff71afe71 in _XimRead (im=im@entry=0x7d49c0, len=len@entry=0x7fffffffc6ee,
buf=buf@entry=0x7fffffffd0e0 "", buf_size=buf_size@entry=2048,
predicate=predicate@entry=0x7ffff719dc00 <_XimSetICValuesCheck>, arg=arg@entry=0x7efc40 "
eG\367\377\177") at ../../../../modules/im/ximcp/imTransR.c:235
#8 0x00007ffff719e8a6 in _XimProtoSetICValues (xic=0x7efc40, arg=<optimized out>) at
../../../../modules/im/ximcp/imDefIc.c:778
#9 0x00007ffff718cb3d in XSetICValues (ic=0x7efc40) at ../../../src/xlibi18n/ICWrap.c:332 #10 0x000000000042a97f in rxvt_term::im_send_spot (this=this@entry=0x76b2d0) at main.C:1271
#11 0x000000000041df89 in rxvt_term::flush (this=0x76b2d0) at command.C:1009
#12 0x00000000004406f0 in ev_invoke_pending () at ./../libev/ev.c:3088
#13 0x000000000044191e in ev_run (flags=<optimized out>) at ./../libev/ev.c:3488
#14 0x0000000000416ec3 in main (argc=1, argv=0x7fffffffdbd8) at rxvt.C:38

(Frame 4 never returns)

Lest you suspect it's a bug in rxvt-unicode, here is another place I've seen the problem:

1. Open up Firefox
2. Run the same script, with focus on a Firefox text box

Firefox doesn't hang, but the output is frequently reordered.

Lest you suspect it's a bug in X11, disabling IBUS (by removing it from XMODIFIERS) solves the problem in both Firefox and rxvt-unicode.

Please provide any additional information below.

I know it's hard to reproduce race conditions. I can do it fairly reliably on my hardware but I have no idea if these instructions will work on other cases. I'm happy to run debug builds of IBUS and help you debug, just let me know what info you need.

I think these two bugs might be related.

https://code.google.com/p/ibus/issues/detail?id=1697
https://code.google.com/p/ibus/issues/detail?id=862

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
You received this message because you are subscribed to the Google
Groups "ibus-devel" group.
iBus project web page: http://code.google.com/p/ibus/
iBus dev group: http://groups.google.com/group/ibus-devel?hl=en
--- You received this message because you are subscribed to the Google Groups "ibus-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

回复