After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 575767 - Crashes when XInput device disappears
Crashes when XInput device disappears
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Class: GdkDevice
2.16.x
Other Linux
: Normal critical
: ---
Assigned To: Jehan
Carlos Garnacho
: 591137 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-03-17 23:28 UTC by Bastien Nocera
Modified: 2013-05-22 21:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fixes crash when XInput device disappears. (5.07 KB, patch)
2013-05-17 14:25 UTC, Jehan
accepted-commit_now Details | Review

Description Bastien Nocera 2009-03-17 23:28:43 UTC
Recent X.org use HAL to detect XInput devices. Recently, linuxwacom got the necessary plumbing to add/remove wacom devices on-the-fly.

I get this crash when disconnecting the wacom tablet:
The program 'gimp-2.6' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadDevice, invalid or uninitialized input device'.
  (Details: serial 115280 error_code 148 request_code 141 minor_code 30) 
  (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.)

(script-fu:5836): LibGimpBase-WARNING **: script-fu: gimp_wire_read(): error

Let me know if you want/need a full backtrace
Comment 1 Martin Nordholts 2009-03-18 05:44:48 UTC
Yes please, provide a backtrace.
Comment 2 Sven Neumann 2009-03-18 08:27:10 UTC
This is basically a duplicate of bug #575768. Without support for hotplug in GTK+, there is not much we can do. If you provide a stack trace we can try to work around the crash though.
Comment 3 Bastien Nocera 2009-04-02 17:33:44 UTC
Don't think we can work around that problem in GIMP though:

  • #0 gdk_x_error
    at gdkmain-x11.c line 614
  • #1 _XError
    at XlibInt.c line 2928
  • #2 _XReply
    at xcb_io.c line 506
  • #3 XQueryDeviceState
    from /usr/lib/libXi.so.6
  • #4 gdk_input_check_proximity
    at gdkinput-xfree.c line 117
  • #5 _gdk_input_enter_event
    at gdkinput-xfree.c line 173
  • #6 gdk_event_translate
    at gdkevents-x11.c line 1293
  • #7 _gdk_events_queue
    at gdkevents-x11.c line 2298
  • #8 gdk_event_dispatch
    at gdkevents-x11.c line 2358
  • #9 g_main_dispatch
    at gmain.c line 1814
  • #10 IA__g_main_context_dispatch
    at gmain.c line 2367
  • #11 g_main_context_iterate
    at gmain.c line 2448
  • #12 IA__g_main_loop_run
    at gmain.c line 2656
  • #13 app_run
  • #14 main

Short-term, GTK+ should at least not crash when a device has disappeared.
Comment 4 Hernando Torque 2009-08-08 12:39:05 UTC
*** Bug 591137 has been marked as a duplicate of this bug. ***
Comment 5 Hernando Torque 2009-08-08 12:43:46 UTC
I can confirm this for GTK+ 2.17.6 (see dupe). Maybe the severity of this bug should be changed to critical as it crashes programs and therefor could cause data loss?
Comment 6 Martin Nordholts 2009-08-08 12:45:08 UTC
Data loss is critical, changing.
Comment 7 Jehan 2013-05-04 23:31:16 UTC
Hello all,

is this bug only affection GTK 2? Or is it also in GTK 3?
Comment 8 Bastien Nocera 2013-05-04 23:54:49 UTC
Only GTK+ 2.x.

GTK+ 3.x uses XInput 2 and supports hotplugging (or unplugging) input devices.
Comment 9 Jehan 2013-05-05 00:00:56 UTC
Bastien: thanks for the answer. So I guess with time, this bug will become less serious, then. As more and more programs would move to GTK3, I guess.
Even though, yes obviously that's still a serious issue for programs on GTK2. :-/
Comment 10 Jehan 2013-05-17 14:25:54 UTC
Created attachment 244542 [details] [review]
Fixes crash when XInput device disappears.

Hey all,

so after some thoughts, I thought that a bunch of programs still use GTK+ 2, and in particular, GIMP will still use it for quite some time (next big version 2.10 for instance). So I looked at this serious crash (when my graphics user uses GIMP for hours, she sometimes touch the usb plug and it disconnects slightly sometimes. And PAF! GIMP crashes. Well that's bad).

Attached is a patch which would simply ignores the XInputExtension errors on selected calls on devices, which are the 3 calls I identified as being crash reasons in all my tests.
And as far as I could test with my tablets, it works great.
Comment 11 Jehan 2013-05-17 14:32:15 UTC
By the way! As for coding style, I was a little unsure, especially in gdk/x11/gdkinput-xfree.c where there was various styles in existing code (sometimes tab indentation, sometimes code block brackets used differently as other places, etc.). So excuse me if I got it wrong, and just tell me which style to use. Isn't it the same as GIMP code?
Comment 12 Michael Natterer 2013-05-19 22:32:40 UTC
The coding style looks ok, and I really like the patch, these GIMP crashes
just because a tablet got unplugged are a major pain.
Comment 13 Jehan 2013-05-19 22:38:14 UTC
Ok cool. So is it ok to push?

I don't know if I have any write rights on the GTK+ repository.
Comment 14 Michael Natterer 2013-05-21 23:02:25 UTC
You have the right, but I don't feel familiar enough with that code
to sign off.
Comment 15 Carlos Garnacho 2013-05-22 20:11:25 UTC
Comment on attachment 244542 [details] [review]
Fixes crash when XInput device disappears.

Given the XI1 state of affairs, the patch does look like the best approach to me. Nice to see this longstanding bug go.
Comment 16 Jehan 2013-05-22 20:51:05 UTC
Ok. Thanks!

Committed on gtk-2-24:

commit 8368de2bc35056d466f0a536eadc353c69c0e6e3
Author: Jehan <jehan@girinstud.io>
Date:   Fri May 17 23:04:40 2013 +0900

    Bug 575767: fix crashes when XInput device disappears.

    Ignore X11 errors from querying state of unplugged input devices.
    GTK+ 3 handle this better with hotplugging support in XInput 2, but
    this is working workaround for avoiding ugly crashes and data loss
    with GTK+ 2.