Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-16404

Handling of XRegisterIMInstantiateCallback and XUnregisterIMInstantiateCallback function prototypes unsafe

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P5: Not important
    • None
    • 4.7.1
    • QPA: X11/XCB
    • None
    • X11
    • Linux/X11

    Description

      In src/gui/kernel/qt_x11_p.h there are hacks in place to try to account for what the code calls "breakage in many versions of XFree86's Xlib.h". Specifically, it would seem that the function prototypes for XRegisterIMInstantiateCallback and XUnregisterIMInstantiateCallback which are defined in X11/Xlib.h seem to be at odds with the Xlib specification. The fifth and sixth parameters seem to have the wrong types compared to the spec, but it would seem that most linux distributions have and continue to use the supposedly incorrect types. Delving into the xorg source code, it would seem that not only the function prototypes, but also the implementations of those functions are using the wrong types. This doesn't mean the implementations are wrong, just that they don't follow the Xlib specification.

      The unfortunate thing about qt_x11_p.h is that it tries to define these prototypes as a mix of the Xlib spec and the common practice. Specifically, it tries to force the type XIMProc instead of XIDProc for the fifth parameter, but this has the effect of now making any code that uses these functions likely to pass invalid data through the fifth parameter (which is a callback function address). Another side effect of how qt_x11_p.h tries to do this is that building Qt with the LSB compilers fails, because qt_x11_p.h relies on Xlib.h not being included before qt_x11_p.h, but this assumption is broken when building the GTK theme module is enabled. This never showed up with the LSB compilers in the past because the X11 headers have only been fleshed out sufficiently to support GTK theme integration as of the latest LSB 4.1 beta packages. For cross-reference, here's the bug in the LSB bugtracker discussing this issue:

      http://bugs.linuxbase.org/show_bug.cgi?id=3145

      The specific update in the LSB packages that now results in this bug being seen is updating the pkgconfig file for gtk+-2.0 where the gtk version has been updated from 2.8.0 to 2.10.0, which is the trigger for enabling GTK theme support in Qt's configure script.

      I've attached a proposed patch which effectively disables the hack in qt_x11_p.h when using LSB compilers, since the Xlib.h contents are fully known in that case. The patch also removes the restriction that Xlib.h cannot be included before qt_x11_p.h, which is a requirement for being able to build Qt with the LSB compilers.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            jirauser11888 user-aa151 (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes