x11: Call XInitThreads()
authorChad Versace <chadversary@google.com>
Tue, 27 Dec 2016 21:47:33 +0000 (13:47 -0800)
committerChad Versace <chadversary@google.com>
Fri, 20 Jan 2017 23:22:11 +0000 (15:22 -0800)
Because the X11 manual says we must.

From man:XInitThreads(3):

  The XInitThreads function initializes Xlib support for concurrent
  threads.  This function must be the first Xlib function
  a multi-threaded program calls, and it must complete before any other
  Xlib call is made.

Fixes crash in multithreaded test:

  Test case 'dEQP-EGL.functional.multithread.window_context'..
  [xcb] Unknown sequence number while processing queue
  [xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
  [xcb] Aborting, sorry about that.
  deqp-egl: xcb_io.c:259: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.

Change-Id: Ib3b535cec8295e062994fd759ae083c78641cf13

framework/platform/X11/tcuX11Platform.cpp

index a34dcdf..eb00635 100644 (file)
@@ -144,5 +144,13 @@ X11Platform::X11Platform (void)
 
 tcu::Platform* createPlatform (void)
 {
+       // From man:XinitThreads(3):
+       //
+       //     The XInitThreads function initializes Xlib support for concurrent
+       //     threads.  This function must be the first Xlib function
+       //     a multi-threaded program calls, and it must complete before any other
+       //     Xlib call is made.
+       DE_CHECK_RUNTIME_ERR(XInitThreads() != 0);
+
        return new tcu::x11::X11Platform();
 }