GNOME Bugzilla – Bug 575767
Crashes when XInput device disappears
Last modified: 2013-05-22 21:11:08 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
Yes please, provide a backtrace.
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.
Don't think we can work around that problem in GIMP though:
+ Trace 214137
Short-term, GTK+ should at least not crash when a device has disappeared.
*** Bug 591137 has been marked as a duplicate of this bug. ***
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?
Data loss is critical, changing.
Hello all, is this bug only affection GTK 2? Or is it also in GTK 3?
Only GTK+ 2.x. GTK+ 3.x uses XInput 2 and supports hotplugging (or unplugging) input devices.
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. :-/
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.
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?
The coding style looks ok, and I really like the patch, these GIMP crashes just because a tablet got unplugged are a major pain.
Ok cool. So is it ok to push? I don't know if I have any write rights on the GTK+ repository.
You have the right, but I don't feel familiar enough with that code to sign off.
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.
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.