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 679736 - Using [Ctrl]+[Shift]+[+] as shortcut in Wacom panel crashes gnome-settings-daemon
Using [Ctrl]+[Shift]+[+] as shortcut in Wacom panel crashes gnome-settings-da...
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: wacom
3.5.x
Other Linux
: Normal major
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
Depends on:
Blocks:
 
 
Reported: 2012-07-11 09:44 UTC by Olivier Fourdan
Modified: 2012-07-11 11:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (899 bytes, patch)
2012-07-11 09:46 UTC, Olivier Fourdan
reviewed Details | Review
Updated patch (909 bytes, patch)
2012-07-11 11:02 UTC, Olivier Fourdan
none Details | Review
wacom: Fix crash for shortcuts requiring Shift (1.06 KB, patch)
2012-07-11 11:37 UTC, Bastien Nocera
none Details | Review
wacom: Fix crash for shortcuts requiring Shift (1.06 KB, patch)
2012-07-11 11:40 UTC, Bastien Nocera
committed Details | Review
wacom: Never try to create fake events with 0 keycode (1.16 KB, patch)
2012-07-11 11:41 UTC, Bastien Nocera
committed Details | Review
wacom: Avoid X errors when calling XTestFakeKeyEvent() (1.15 KB, patch)
2012-07-11 11:41 UTC, Bastien Nocera
committed Details | Review

Description Olivier Fourdan 2012-07-11 09:44:29 UTC
Defining a shortcut as [Ctrl]+[Shift]+[+] in gnome-control-center for a pad button and pressing the pad button will crash gnome-settings-daemon with a BadValue XError.

(gnome-settings-daemon:23040): wacom-plugin-DEBUG: Received event button press 'buttonB' ('2') on device 'Wacom Intuos5 touch M' ('16')
(gnome-settings-daemon:23040): wacom-plugin-DEBUG: Emitting '<Primary><Shift>plus' (keyval: 43, keycode: 0 mods: 0x5)

(gnome-settings-daemon:23040): Gdk-ERROR **: The program 'gnome-settings-daemon' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadValue (integer parameter out of range for operation)'.
  (Details: serial 1170 error_code 2 request_code 142 minor_code 2)
  (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 GDK_SYNCHRONIZE environment
   variable to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
Trace/breakpoint trap

Notice the "keycode: 0" in the debug logs, that's what passed to XTestFakeKeyEvent() in generate_key() and that causes a BadValue XError because 0 is not a valid keycode.

This is bacause the keycode is not found in the current group so it needs to be looked in group 0, but the code checks for "level > 0" no "group > 0" thus no keycode is found and 0 is passed.
Comment 1 Olivier Fourdan 2012-07-11 09:46:41 UTC
Created attachment 218523 [details] [review]
Proposed patch

Patch tofix the issue.

Before:

gnome-settings-daemon:22325): wacom-plugin-DEBUG: Received event button press 'buttonB' ('2') on device 'Wacom Intuos5 touch M' ('16')
(gnome-settings-daemon:22325): wacom-plugin-DEBUG: Emitting '<Primary><Shift>plus' (keyval: 43, keycode: 0 mods: 0x5)

=> BadValue on keycode

After:

(gnome-settings-daemon:2056): wacom-plugin-DEBUG: Received event button press 'buttonB' ('2') on device 'Wacom Intuos5 touch M' ('16')
(gnome-settings-daemon:2056): wacom-plugin-DEBUG: Emitting '<Primary><Shift>plus' (keyval: 43, keycode: 21 mods: 0x5)

Event is generated
Comment 2 Bastien Nocera 2012-07-11 09:59:54 UTC
Review of attachment 218523 [details] [review]:

Need a better explanation than that.
Comment 3 Olivier Fourdan 2012-07-11 10:19:05 UTC
What part exactly needs better explanation?

The comment says:

    /* Couldn't find it in the current group? Look in group 0 */

The code does:

    for (i = 0; i < n_keys; i++) {
        if (keys[i].level > 0)
            continue;
        keycode = keys[i].keycode;
    }

Checking for "level > 0" no keycode is found and keycode remains 0 and that is not a valid keycode to pass to XTestFakeKeyEvent()

Using "group" fixes that so I think you meant "group" here, not "level" based on your comment and the code.
Comment 4 Bastien Nocera 2012-07-11 10:24:38 UTC
(In reply to comment #3)
> What part exactly needs better explanation?

The commit log message. "Because that makes it work" isn't a _reason_ for a change, it's the result of a change.
Comment 5 Olivier Fourdan 2012-07-11 11:02:40 UTC
Created attachment 218534 [details] [review]
Updated patch

(In reply to comment #4)
> (In reply to comment #3)
> > What part exactly needs better explanation?
> 
> The commit log message. "Because that makes it work" isn't a _reason_ for a
> change, it's the result of a change.

Humm, I still don't get what you mean here, the commit log doesn't read "because that makes it work", it reads "Use field group not level in keymaps otherwise some keycode won't be found" which is the reason for the change I believe.

It now reads "use keymap group to search group 0 in case the keycode isn't found in current group", would that be better?
Comment 6 Bastien Nocera 2012-07-11 11:37:55 UTC
Created attachment 218538 [details] [review]
wacom: Fix crash for shortcuts requiring Shift

As per code comment, we want to ignore non-zero groups,
not non-zero levels, otherwise we wouldn't be able to
find keycodes for keysyms that require Shift.

Fixes crasher pressing a button with "Ctrl+Alt++" associated to it.
Comment 7 Bastien Nocera 2012-07-11 11:40:18 UTC
Created attachment 218540 [details] [review]
wacom: Fix crash for shortcuts requiring Shift

As per code comment, we want to ignore non-zero groups,
not non-zero levels, otherwise we wouldn't be able to
find keycodes for keysyms that require Shift.

Fixes crasher pressing a button with "Ctrl+Alt++" associated to it.
Comment 8 Bastien Nocera 2012-07-11 11:41:00 UTC
Created attachment 218541 [details] [review]
wacom: Never try to create fake events with 0 keycode

XTestFakeKeyEvent() doesn't like it.
Comment 9 Bastien Nocera 2012-07-11 11:41:11 UTC
Created attachment 218542 [details] [review]
wacom: Avoid X errors when calling XTestFakeKeyEvent()
Comment 10 Bastien Nocera 2012-07-11 11:41:46 UTC
Attachment 218540 [details] pushed as 7a55cc7 - wacom: Fix crash for shortcuts requiring Shift
Attachment 218541 [details] pushed as 09ad656 - wacom: Never try to create fake events with 0 keycode
Attachment 218542 [details] pushed as 67f96d4 - wacom: Avoid X errors when calling XTestFakeKeyEvent()