Hi Walter,

On 11.09.2017 09:11, walter harms wrote:
> Hi Jacek,
> while it worked in the latest release of libX11 i was unable to
> replicate the crash with the current git version.
> Can you confirm my observation ?

The race is there since the code was introduced, so release version is
also affected. As usually with races, it's random so maybe it just
didn't happen there. I attached a version of the test that tries harder
to reproduce the problem. Do you see a crash or hang with this test and
release version of libX11? It does the same thing as previous test, but
multiple times so chances of hitting the problem are much higher.

Thanks,
Jacek
#include <assert.h>
#include <X11/Xlib.h>
#include <pthread.h>

#define NTHREADS 10
#define NITERATIONS 50

static Display *display;

static void *thread_proc(void *arg)
{
    int i = NITERATIONS;
    while(i--)
        XOpenIM(display, NULL, NULL, NULL);
    return NULL;
}

int main()
{
    pthread_t threads[NTHREADS];
    int i, r;

    r = XInitThreads();
    assert(r);

    display = XOpenDisplay(NULL);
    assert(display != NULL);

    for (i = 0; i < NTHREADS; i++) {
        r = pthread_create(threads + i, NULL, thread_proc, NULL);
        assert(!r);
    }

    for (i = 0; i < NTHREADS; i++) {
        r = pthread_join(threads[i], NULL);
        assert(!r);
    }

    return 0;
}
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to