x11: Call XInitThreads()
authorChad Versace <chadversary@google.com>
Mon, 13 Nov 2017 11:02:02 +0000 (13:02 +0200)
committerTapani Pälli <tapani.palli@intel.com>
Mon, 13 Nov 2017 11:12:19 +0000 (13:12 +0200)
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.

(See also Vulkan spec section "Xlib Platform")

Fixes crash in multithreaded test:

  Test case 'dEQP-EGL.functional.multithread.window'..
  [xcb] Unknown request in queue while dequeuing
  [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:165: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed.
  Aborted (core dumped)

Change-Id: I2124be592a8d2d9036423cc2f0d71066e0e22939

framework/platform/lnx/X11/tcuLnxX11.cpp

index 3f72b2b..5aef054 100644 (file)
@@ -55,6 +55,13 @@ WindowBase::~WindowBase (void)
 XlibDisplay::XlibDisplay (EventState& eventState, const char* name)
        : DisplayBase   (eventState)
 {
+       // 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);
        m_display = XOpenDisplay((char*)name); // Won't modify argument string.
        if (!m_display)
                throw ResourceError("Failed to open display", name, __FILE__, __LINE__);