[Xcb] [Bug 57022] New: xkb crash when iterating xcb_xkb_get_map() data.

Christoph Reimann chrr at arcor.de
Mon Nov 12 09:31:01 PST 2012


Hi, I don't have a running XCB version at the moment, but maybe this will
help:
As far as I remember, there should be a call to xcb_xkb_get_map_map_unpack.
See below for a function from test code I wrote > two years ago [1].
Hope that helps,
Christoph

[1] http://cgit.freedesktop.org/~chr/check_xkb/tree/xkb_util.c

xcb_xkb_get_map_reply_t *
xcb_xkb_util_get_map(xcb_connection_t      *c,
             xcb_xkb_device_spec_t  device_spec,
             uint16_t               map_components,
             xcb_xkb_get_map_map_t *_aux,
             xcb_generic_error_t  **e) {
  xcb_xkb_get_map_cookie_t cookie;
  xcb_xkb_get_map_reply_t *reply;
  void *buffer;

  cookie =  xcb_xkb_get_map (c, device_spec, map_components,
                 0, /* partial */
                 0, /* firstType */
                 0, /* nTypes */
                 0, /* firstKeySym */
                 0, /* nKeySyms */
                 0, /* firstKeyAction */
                 0, /* nKeyActions */
                 0, /* firstKeyBehavior */
                 0, /* nKeyBehaviors */
                 0, /* virtualMods */
                 0, /* firstKeyExplicit */
                 0, /* nKeyExplicit */
                 0, /* firstModMapKey */
                 0, /* nModMapKeys */
                 0, /* firstVModMapKey */
                 0  /* nVModMapKeys */);

  reply = xcb_xkb_get_map_reply (c, cookie, e);

  if (!(*e)) {
    buffer = xcb_xkb_get_map_map(reply);
    xcb_xkb_get_map_map_unpack (buffer, reply->nTypes, reply->nKeySyms,
reply->nKeyActions,
                reply->totalActions, reply->totalKeyBehaviors,
reply->nVModMapKeys,
                reply->totalKeyExplicit, reply->totalModMapKeys,
reply->totalVModMapKeys,
                reply->present, _aux);
  }

  return reply;
}


On 12 November 2012 18:01, <bugzilla-daemon at freedesktop.org> wrote:

>  Priority medium  Bug ID 57022<https://bugs.freedesktop.org/show_bug.cgi?id=57022>
> Assignee xcb at lists.freedesktop.org  Summary xkb crash when iterating
> xcb_xkb_get_map() data.  QA Contact xcb at lists.freedesktop.org  Severity normal
>  Classification Unclassified  OS All  Reporter gatis.paeglis at digia.com
> Hardware Other  Status NEW  Version unspecified  Component Library
> Product XCB
>
>  Fallowing example always crashes when trying to read data returned from
> xcb_xkb_get_map(). Tested with both real and virtual modifiers, unable to read
> keycodes.
>
>     xcb_xkb_get_map_cookie_t map_cookie;
>     xcb_xkb_get_map_reply_t *map_reply;
>     xcb_generic_error_t *map_error = 0;
>
>     map_cookie = xcb_xkb_get_map(xcb_connection(),
>                                  XCB_XKB_ID_USE_CORE_KBD,
>                                  XCB_XKB_MAP_PART_VIRTUAL_MOD_MAP |
>                                  XCB_XKB_MAP_PART_KEY_TYPES |
>                                  XCB_XKB_MAP_PART_KEY_SYMS |
>                                  XCB_XKB_MAP_PART_EXPLICIT_COMPONENTS |
>                                  XCB_XKB_MAP_PART_KEY_ACTIONS |
>                                  XCB_XKB_MAP_PART_KEY_BEHAVIORS |
>                                  XCB_XKB_MAP_PART_VIRTUAL_MODS |
>                                  XCB_XKB_MAP_PART_MODIFIER_MAP,
>                                  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); // hmm
>
>     map_reply = xcb_xkb_get_map_reply(xcb_connection(), map_cookie,
> &map_error);
>     if (map_error) {
>         free(map_error);
>         return;
>     }
>
>     const xcb_xkb_get_map_map_t *map = (xcb_xkb_get_map_map_t
> *)xcb_xkb_get_map_map(map_reply);
>
>
>     xcb_xkb_key_v_mod_map_iterator_t iter =
> xcb_xkb_get_map_map_vmodmap_rtrn_iterator(map_reply, map);
>     xcb_keycode_t key = 0;
>     while (iter.rem) {
>         if (iter.data) {
>             key = iter.data->keycode; // <----- CRASH
>             xcb_xkb_key_v_mod_map_next(&iter);
>         }
>     }
>
>  ------------------------------
> You are receiving this mail because:
>
>    - You are the QA Contact for the bug.
>    - You are the assignee for the bug.
>
>
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20121112/fa97262a/attachment-0001.html>


More information about the Xcb mailing list