Xpra: Ticket #126: Certain keypresses in SAS which ring the bell cause xpra client to crash

While running the Linux SAS 9.2 GUI application in xpra (Linux xpra server and Linux xpra client), most things work fine. However, certain keypresses which the application considers "invalid," such as pressing the up arrow when already at the top of a text area, cause the xpra client to crash and disconnect. The application continues running in the server and can be re-attached to without any problems, until another "invalid" keystroke crashes the xpra client again.

The problem appears to occur when the application attempts to ring the bell in response to the invalid keypress. The error given is: 'XI_BadDevice (invalid Device parameter)'. (Details: serial 214105 error_code 160 request_code 147 minor_code 3)

When run with --debug=all, the relevant portions seem to be (full log attached):

~> xpra --debug=all attach ssh:pt-sas06:100
set default window icon to /usr/bin/../share/xpra/icons/xpra.png
bell_toggled((<gtk.CheckMenuItem object at 0xd6ebe0 (GtkCheckMenuItem at 0xa750d0)>,)) bell_enabled=True
cursors_toggled((<gtk.CheckMenuItem object at 0xd6ec80 (GtkCheckMenuItem at 0xa75190)>,)) cursors_enabled=True
[...]
handle_key_action(<gtk.gdk.Event at 0x10119e0: GDK_KEY_PRESS keyval=Up>,<ClientWindow object at 0x10d81e0 (xpra+client+ClientWindow at 0xf8a610)>,True)
key_action(<gtk.gdk.Event at 0x10119e0: GDK_KEY_PRESS keyval=Up>,<ClientWindow object at 0x10d81e0 (xpra+client+ClientWindow at 0xf8a610)>,True) modifiers=['mod2'], name=Up, state=<flags GDK_MOD2_MASK of type GdkModifierType>, keyval=65362, string=, keycode=111
scheduling key repeat for Up: delay=400, interval=5 (from 500 and 28)
key repeat: starting timer for Up / 111 with delay 400 and interval 5
read thread: got data 'Bm\x14\x1b\x9b\x01\xd3zRjNN&h\xf7\x120\xa5\x83k\\\x10\x1bD\x80\x91\x81U*\x00\x00\x00\xff\xff'
_process_bell(['bell', 0, 1, 50, 400, 100, 0, 0, '']) gdkwindow=<gtk.gdk.Window object at 0x10c7c30 (GdkWindow at 0xa78120)>
The program 'xpra' received an X Window System error.
This probably reflects a bug in the program.
The error was 'XI_BadDevice (invalid Device parameter)'.
  (Details: serial 1388 error_code 160 request_code 147 minor_code 3)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)


Tue, 15 May 2012 17:21:10 GMT - alis: attachment set

stdout/stderr log of xpra client


Tue, 15 May 2012 17:22:59 GMT - Antoine Martin: status changed

I believe this is fixed in trunk, see #93 and r772


Wed, 23 May 2012 19:45:02 GMT - Antoine Martin:

Does v0.3.0 fix this for you?

In any case, would you mind trying this patch:

Index: src/xpra/client.py
===================================================================
--- src/xpra/client.py	(revision 865)
+++ src/xpra/client.py	(working copy)
@@ -1077,6 +1077,7 @@
         if gdkwindow is None:
             gdkwindow = gdk.get_default_root_window()
         log("_process_bell(%s) gdkwindow=%s", packet, gdkwindow)
+        device = 0
         self._client_extras.system_bell(gdkwindow, device, percent, pitch, duration, bell_class, bell_id, bell_name)
     def _process_notify_show(self, packet):

I believe the device number is not portable from client to server so we should always use XkbUseCoreKbd (zero) here.

This is probably a better fix as it will ensure the bell does ring, rather than silently ignoring the X11 error that was causing the crash previously.


Thu, 24 May 2012 17:56:28 GMT - alis:

The change in r772 does fix the problem of the crashes.

The device=0 patch above, however, does not seem to work. I still get the "error using device_bell: 160, will fallback to gdk beep" message when I have the r772 patch installed, and a crash without r772 in. It looks like device=0 already in all of my tests.


Sun, 03 Jun 2012 17:40:51 GMT - Antoine Martin: status changed; resolution set

oh well, I give up, I don't understand this bell_class/bell_id/device business (the docs are not particularly helpful)


Mon, 10 Dec 2012 09:57:53 GMT - Antoine Martin:

r2229 forces:

as we should not be using the device-ids from the server.


Sat, 23 Jan 2021 04:46:15 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/126