Comment 21 for bug 86103

Revision history for this message
In , Son-two (son-two) wrote :

during investigation of Sun's bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6532373 I've found that the cause of the problem is in XCB, not in Sun's code. I've developed the small test to demonstrate the problem. The test is very simple: it calls LockDisplay() and _XReply(), in usual situation it hangs because there is no replies, but on in bad it throws the assertion. To reproduce the problem you need to build the test on platform which doesn't have xcb and then run it on a platform with xcb.

Here is the test (made from source of Xinerama by removing most of the code):

#include <X11/Xlib.h>
#include <X11/Xlibint.h>
#include <X11/Xos.h>
#include <X11/Xutil.h>
#include "Xext.h" /* in ../include */
#include "extutil.h" /* in ../include */
#include "panoramiXext.h"
#include "panoramiXproto.h" /* in ../include */

#include <stdio.h>

static XExtensionInfo _panoramiX_ext_info_data;
static XExtensionInfo *panoramiX_ext_info = &_panoramiX_ext_info_data;
static /* const */ char *panoramiX_extension_name = PANORAMIX_PROTOCOL_NAME;

#define PanoramiXCheckExtension(dpy,i,val) \
  XextCheckExtension (dpy, i, panoramiX_extension_name, val)
#define PanoramiXSimpleCheckExtension(dpy,i) \
  XextSimpleCheckExtension (dpy, i, panoramiX_extension_name)

static int close_display();
static /* const */ XExtensionHooks panoramiX_extension_hooks = {
    NULL, /* create_gc */
    NULL, /* copy_gc */
    NULL, /* flush_gc */
    NULL, /* free_gc */
    NULL, /* create_font */
    NULL, /* free_font */
    close_display, /* close_display */
    NULL, /* wire_to_event */
    NULL, /* event_to_wire */
    NULL, /* error */
    NULL, /* error_string */
};
static XEXT_GENERATE_FIND_DISPLAY (find_display, panoramiX_ext_info,
                                   panoramiX_extension_name,
                                   &panoramiX_extension_hooks,
                                   0, NULL)
static XEXT_GENERATE_CLOSE_DISPLAY (close_display, panoramiX_ext_info)

Status XPanoramiXQueryVersion(
    Display *dpy,
    int *major_versionp,
    int *minor_versionp
)
{
/* XExtDisplayInfo *info = find_display (dpy); */
    xPanoramiXQueryVersionReply rep;
/* xPanoramiXQueryVersionReq *req; */

/* PanoramiXCheckExtension (dpy, info, 0); */

    LockDisplay (dpy);
/* GetReq (PanoramiXQueryVersion, req); */
/* req->reqType = info->codes->major_opcode; */
/* req->panoramiXReqType = X_PanoramiXQueryVersion; */
/* req->clientMajor = PANORAMIX_MAJOR_VERSION; */
/* req->clientMinor = PANORAMIX_MINOR_VERSION; */
    if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
        UnlockDisplay (dpy);
        SyncHandle ();
        return 0;
    }
    *major_versionp = rep.majorVersion;
    *minor_versionp = rep.minorVersion;
    UnlockDisplay (dpy);
    SyncHandle ();
    return 1;
}

int main(int argc, char **argv)
{
    Display *display;
    int major_version;
    int minor_version;

    char *display_name = NULL;
    if ((display = XOpenDisplay(display_name)) == NULL)
    {
        fprintf(stderr, "Couldn't open %s\n", XDisplayName(display_name));
        return -1;
    }

    XPanoramiXQueryVersion(display, &major_version, &minor_version);
    return 0;
}