Bug 67654

Summary: Fails to parse a keymap retrieved from XQuartz
Product: libxkbcommon Reporter: Gatis Paeglis <gatis.paeglis>
Component: GeneralAssignee: Daniel Stone <daniel>
Status: RESOLVED FIXED QA Contact: Ran Benita <ran234>
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: the keymap
0001-keymap-dump-use-correct-format-specifiers.patch
0002-xkbcomp-handle-empty-keymaps.patch
0003-scanner-allow-empty-key-name-literals.patch

Description Gatis Paeglis 2013-08-02 08:11:52 UTC
Created attachment 83506 [details]
the keymap

xkbcommon fails to parse a kaymap retrieved from XQuartz (Apple Inc.'s version of the X server) when runing a xkbcommon based application in X session from Mac to Ubuntu.

The keymap: http://pastebin.com/nxVL9h5t

X tool 'xkbcomp' accepts it, but xkbcommon fails with a following message:

Error: Failed to compile xkb_symbols
Error: Failed to compile keymap
Comment 1 Gatis Paeglis 2013-08-02 08:33:36 UTC
In the same enviroment "xprop -root | grep -i xkb" returns: _XKB_RULES_NAMES(STRING) = "base", "empty", "empty", "", ""

and passing these values to xkb_keymap_new_from_names crahes with a following backtrace:

(gdb) bt
#0  0xb32efab5 in XkbKeyGroupWidth (key=0x808be50, layout=0) at ../../../3rdparty/xkbcommon/src/keymap.h:423
#1  0xb32efe1c in ApplyInterpsToKey (keymap=0x808bce8, key=0x808be50) at ../../../3rdparty/xkbcommon/src/xkbcomp/keymap.c:146
#2  0xb32efe90 in UpdateDerivedKeymapFields (keymap=0x808bce8) at ../../../3rdparty/xkbcommon/src/xkbcomp/keymap.c:190
#3  0xb32f0683 in CompileKeymap (file=0x0, keymap=0x808bce8, merge=MERGE_OVERRIDE) at ../../../3rdparty/xkbcommon/src/xkbcomp/keymap.c:332
#4  0xb32ff9d9 in compile_keymap_file (keymap=0x808bce8, file=0x808c460) at ../../../3rdparty/xkbcommon/src/xkbcomp/xkbcomp.c:43
#5  0xb32ffc26 in text_v1_keymap_new_from_names (keymap=0x808bce8, rmlvo=0xbfffebd0) at ../../../3rdparty/xkbcommon/src/xkbcomp/xkbcomp.c:94
#6  0xb32e02ed in xkb_keymap_new_from_names (ctx=0x808b290, rmlvo_in=0x808b24c, flags=XKB_MAP_COMPILE_PLACEHOLDER)
    at ../../../3rdparty/xkbcommon/src/xkb-keymap.c:179
Comment 2 Ran Benita 2013-08-02 08:42:02 UTC
Hi Gatis,
I think the following patches should fix this. Can you please test them?
Comment 3 Ran Benita 2013-08-02 08:42:37 UTC
Created attachment 83511 [details]
0001-keymap-dump-use-correct-format-specifiers.patch
Comment 4 Ran Benita 2013-08-02 08:43:16 UTC
Created attachment 83512 [details] [review]
0002-xkbcomp-handle-empty-keymaps.patch
Comment 5 Ran Benita 2013-08-02 08:43:53 UTC
Created attachment 83513 [details] [review]
0003-scanner-allow-empty-key-name-literals.patch
Comment 6 Gatis Paeglis 2013-08-02 09:11:01 UTC
Just tested, no more errors from the parsing side. Now the question is why Apple provide key mappings only for few keys :) The only characters i can input is 'a' and 'A'.
Comment 7 Ran Benita 2013-08-02 09:20:50 UTC
OK, thanks. I tried my best to make sure it doesn't break anything else, though I'm still a *bit* worried. So I'll wait a day or two before committing.

(In reply to comment #6)
> Just tested, no more errors from the parsing side. Now the question is why
> Apple provide key mappings only for few keys :) The only characters i can
> input is 'a' and 'A'.

I'd guess it's just a placeholder to get X out of the way, and then the keys come from somewhere else.. It doesn't make much sense otherwise.
Comment 8 Ran Benita 2013-08-03 17:46:41 UTC
Now in git.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.