[Xcb] [Bug 41870] New: XSync never return , when XNextEvent runs in separate thread

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Mon Oct 17 04:35:05 PDT 2011


             Bug #: 41870
           Summary: XSync never return , when XNextEvent runs in separate
    Classification: Unclassified
           Product: XCB
           Version: unspecified
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: critical
          Priority: medium
         Component: Library
        AssignedTo: xcb at lists.freedesktop.org
        ReportedBy: arvind.umrao at oracle.com
         QAContact: xcb at lists.freedesktop.org

With libx11-xcb, XSync never returns, when XnextEvent run in separate thread,
causing Java application crash.  With legacy libX11 XSync never hang, it should
be the same case with libX11-xcb. To reproduce the problem, please compile code
with cc sample.c -lX11, then run it. You will not see any print messages.  


Display *dsp;
Window win;
int screen;
XEvent evt;

void * mythread(void *arg) {

    XSelectInput(dsp, win, ExposureMask | ButtonPressMask);
    while (1) {
        XNextEvent(dsp, &evt); /* Lock Display in S11 */
        switch (evt.type) {
            case Expose:
            case ButtonPress:
                fprintf(stderr, "Button pressed in thread\n");

int main(int ac, char *av[]) {

    pthread_t tid_a;
    int arg_thread = 100;

    XEvent ev;

    if ((dsp = XOpenDisplay("")) == NULL) {
        fprintf(stderr, "Can not open Display\n");
        return (-1);

    screen = DefaultScreen(dsp);
    win = XCreateSimpleWindow(dsp, DefaultRootWindow(dsp), 10, 10, 200, 100,
            5, WhitePixel(dsp, screen), BlackPixel(dsp, screen));
    XMapRaised(dsp, win);

    int status = pthread_create(&tid_a, NULL, mythread, &arg_thread);

    /* do some long task */

    XSync(dsp, True); /* <= hung here */

    /* Execution never comes here */

    fprintf(stderr, "\nWith legacy libX11 you can see this messsage \n");
    fprintf(stderr, "But with libX11-xcb you will never see this message.\n");

    /* wait threads */
    status = pthread_join(tid_a, NULL);
    return (0);

Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA Contact for the bug.
You are the assignee for the bug.

More information about the Xcb mailing list