19154747 X application crashed with Assertion failed: xcb_xlib_threads_sequence_lost
authorravi kumar <ravi.n.kumar@oracle.com>
Wed Apr 12 06:57:07 2017 +0000 (2017-04-12)
changeset 170576aff95e6534
parent 1704 4c67bc06f3ac
child 1706 f2af07bcb48f
19154747 X application crashed with Assertion failed: xcb_xlib_threads_sequence_lost
open-src/lib/libX11/19154747.patch
open-src/lib/libX11/Makefile
open-src/lib/libxcb/19154747.patch
open-src/lib/libxcb/Makefile
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/open-src/lib/libX11/19154747.patch	Wed Apr 12 06:57:07 2017 +0000
     1.3 @@ -0,0 +1,722 @@
     1.4 +From a72d2d06c002b644b7040a0a9936c8525e092ba8 Mon Sep 17 00:00:00 2001
     1.5 +From: Christian Linhart <chris@demorecorder.com>
     1.6 +Date: Mon, 7 Sep 2015 17:17:32 +0200
     1.7 +Subject: fix for Xlib 32-bit request number issues
     1.8 +
     1.9 +Make use of the new 64-bit sequence number API in XCB 1.11.1 to avoid
    1.10 +the 32-bit sequence number wrap in libX11.
    1.11 +
    1.12 +Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=71338
    1.13 +Signed-off-by: Christian Linhart <chris@demorecorder.com>
    1.14 +Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
    1.15 +Reviewed-by: Adam Jackson <ajax@redhat.com>
    1.16 +
    1.17 +diff --git a/configure.ac b/configure.ac
    1.18 +index 92b791c..14ad543 100644
    1.19 +--- a/configure.ac
    1.20 ++++ b/configure.ac
    1.21 +@@ -68,8 +68,8 @@ AC_SUBST(LDFLAGS_FOR_BUILD)
    1.22 + # Checks for pkg-config packages
    1.23 + 
    1.24 + # Always required
    1.25 +-X11_REQUIRES='xproto >= 7.0.17 xextproto xtrans xcb >= 1.1.92'
    1.26 +-X11_EXTRA_DEPS="xcb >= 1.1.92"
    1.27 ++X11_REQUIRES='xproto >= 7.0.17 xextproto xtrans xcb >= 1.11'
    1.28 ++X11_EXTRA_DEPS="xcb >= 1.11"
    1.29 + 
    1.30 + PKG_PROG_PKG_CONFIG()
    1.31 + 
    1.32 +diff --git a/src/ClDisplay.c b/src/ClDisplay.c
    1.33 +index bddd773..aa904e5 100644
    1.34 +--- a/src/ClDisplay.c
    1.35 ++++ b/src/ClDisplay.c
    1.36 +@@ -65,7 +65,7 @@ XCloseDisplay (
    1.37 + 		    (*ext->close_display)(dpy, &ext->codes);
    1.38 + 	    }
    1.39 + 	    /* if the closes generated more protocol, sync them up */
    1.40 +-	    if (dpy->request != dpy->last_request_read)
    1.41 ++	    if (X_DPY_GET_REQUEST(dpy) != X_DPY_GET_LAST_REQUEST_READ(dpy))
    1.42 + 		XSync(dpy, 1);
    1.43 + 	}
    1.44 + 	xcb_disconnect(dpy->xcb->connection);
    1.45 +diff --git a/src/Font.c b/src/Font.c
    1.46 +index 650bc6f..a73f9b1 100644
    1.47 +--- a/src/Font.c
    1.48 ++++ b/src/Font.c
    1.49 +@@ -105,7 +105,7 @@ XFontStruct *XLoadQueryFont(
    1.50 +       return font_result;
    1.51 +     LockDisplay(dpy);
    1.52 +     GetReq(OpenFont, req);
    1.53 +-    seq = dpy->request;
    1.54 ++    seq = dpy->request; /* Can't use extended sequence number here */
    1.55 +     nbytes = req->nbytes  = name ? strlen(name) : 0;
    1.56 +     req->fid = fid = XAllocID(dpy);
    1.57 +     req->length += (nbytes+3)>>2;
    1.58 +diff --git a/src/GetAtomNm.c b/src/GetAtomNm.c
    1.59 +index 32de50d..d7f06e3 100644
    1.60 +--- a/src/GetAtomNm.c
    1.61 ++++ b/src/GetAtomNm.c
    1.62 +@@ -87,8 +87,8 @@ char *XGetAtomName(
    1.63 + }
    1.64 + 
    1.65 + typedef struct {
    1.66 +-    unsigned long start_seq;
    1.67 +-    unsigned long stop_seq;
    1.68 ++    uint64_t start_seq;
    1.69 ++    uint64_t stop_seq;
    1.70 +     Atom *atoms;
    1.71 +     char **names;
    1.72 +     int idx;
    1.73 +@@ -107,10 +107,11 @@ Bool _XGetAtomNameHandler(
    1.74 +     register _XGetAtomNameState *state;
    1.75 +     xGetAtomNameReply replbuf;
    1.76 +     register xGetAtomNameReply *repl;
    1.77 ++    uint64_t last_request_read = X_DPY_GET_LAST_REQUEST_READ(dpy);
    1.78 + 
    1.79 +     state = (_XGetAtomNameState *)data;
    1.80 +-    if (dpy->last_request_read < state->start_seq ||
    1.81 +-	dpy->last_request_read > state->stop_seq)
    1.82 ++    if (last_request_read < state->start_seq ||
    1.83 ++	last_request_read > state->stop_seq)
    1.84 + 	return False;
    1.85 +     while (state->idx < state->count && state->names[state->idx])
    1.86 + 	state->idx++;
    1.87 +@@ -152,7 +153,7 @@ XGetAtomNames (
    1.88 +     int missed = -1;
    1.89 + 
    1.90 +     LockDisplay(dpy);
    1.91 +-    async_state.start_seq = dpy->request + 1;
    1.92 ++    async_state.start_seq = X_DPY_GET_REQUEST(dpy) + 1;
    1.93 +     async_state.atoms = atoms;
    1.94 +     async_state.names = names_return;
    1.95 +     async_state.idx = 0;
    1.96 +@@ -165,7 +166,7 @@ XGetAtomNames (
    1.97 +     for (i = 0; i < count; i++) {
    1.98 + 	if (!(names_return[i] = _XGetAtomName(dpy, atoms[i]))) {
    1.99 + 	    missed = i;
   1.100 +-	    async_state.stop_seq = dpy->request;
   1.101 ++	    async_state.stop_seq = X_DPY_GET_REQUEST(dpy);
   1.102 + 	}
   1.103 +     }
   1.104 +     if (missed >= 0) {
   1.105 +diff --git a/src/GetWAttrs.c b/src/GetWAttrs.c
   1.106 +index c10824c..0f5f7bb 100644
   1.107 +--- a/src/GetWAttrs.c
   1.108 ++++ b/src/GetWAttrs.c
   1.109 +@@ -30,8 +30,8 @@ in this Software without prior written authorization from The Open Group.
   1.110 + #include "Xlibint.h"
   1.111 + 
   1.112 + typedef struct _WAttrsState {
   1.113 +-    unsigned long attr_seq;
   1.114 +-    unsigned long geom_seq;
   1.115 ++    uint64_t attr_seq;
   1.116 ++    uint64_t geom_seq;
   1.117 +     XWindowAttributes *attr;
   1.118 + } _XWAttrsState;
   1.119 + 
   1.120 +@@ -47,10 +47,11 @@ _XWAttrsHandler(
   1.121 +     xGetWindowAttributesReply replbuf;
   1.122 +     register xGetWindowAttributesReply *repl;
   1.123 +     register XWindowAttributes *attr;
   1.124 ++    uint64_t last_request_read = X_DPY_GET_LAST_REQUEST_READ(dpy);
   1.125 + 
   1.126 +     state = (_XWAttrsState *)data;
   1.127 +-    if (dpy->last_request_read != state->attr_seq) {
   1.128 +-	if (dpy->last_request_read == state->geom_seq &&
   1.129 ++    if (last_request_read != state->attr_seq) {
   1.130 ++	if (last_request_read == state->geom_seq &&
   1.131 + 	    !state->attr &&
   1.132 + 	    rep->generic.type == X_Error &&
   1.133 + 	    rep->error.errorCode == BadDrawable)
   1.134 +@@ -99,7 +100,7 @@ _XGetWindowAttributes(
   1.135 + 
   1.136 +     GetResReq(GetWindowAttributes, w, req);
   1.137 + 
   1.138 +-    async_state.attr_seq = dpy->request;
   1.139 ++    async_state.attr_seq = X_DPY_GET_REQUEST(dpy);
   1.140 +     async_state.geom_seq = 0;
   1.141 +     async_state.attr = attr;
   1.142 +     async.next = dpy->async_handlers;
   1.143 +@@ -109,7 +110,7 @@ _XGetWindowAttributes(
   1.144 + 
   1.145 +     GetResReq(GetGeometry, w, req);
   1.146 + 
   1.147 +-    async_state.geom_seq = dpy->request;
   1.148 ++    async_state.geom_seq = X_DPY_GET_REQUEST(dpy);
   1.149 + 
   1.150 +     if (!_XReply (dpy, (xReply *)&rep, 0, xTrue)) {
   1.151 + 	DeqAsyncHandler(dpy, &async);
   1.152 +diff --git a/src/IntAtom.c b/src/IntAtom.c
   1.153 +index 3042b65..d9c6c58 100644
   1.154 +--- a/src/IntAtom.c
   1.155 ++++ b/src/IntAtom.c
   1.156 +@@ -188,8 +188,8 @@ XInternAtom (
   1.157 + }
   1.158 + 
   1.159 + typedef struct {
   1.160 +-    unsigned long start_seq;
   1.161 +-    unsigned long stop_seq;
   1.162 ++    uint64_t start_seq;
   1.163 ++    uint64_t stop_seq;
   1.164 +     char **names;
   1.165 +     Atom *atoms;
   1.166 +     int count;
   1.167 +@@ -208,10 +208,12 @@ Bool _XIntAtomHandler(
   1.168 +     register int i, idx = 0;
   1.169 +     xInternAtomReply replbuf;
   1.170 +     register xInternAtomReply *repl;
   1.171 ++    uint64_t last_request_read = X_DPY_GET_LAST_REQUEST_READ(dpy);
   1.172 + 
   1.173 +     state = (_XIntAtomState *)data;
   1.174 +-    if (dpy->last_request_read < state->start_seq ||
   1.175 +-	dpy->last_request_read > state->stop_seq)
   1.176 ++
   1.177 ++    if (last_request_read < state->start_seq ||
   1.178 ++	last_request_read > state->stop_seq)
   1.179 + 	return False;
   1.180 +     for (i = 0; i < state->count; i++) {
   1.181 + 	if (state->atoms[i] & 0x80000000) {
   1.182 +@@ -252,7 +254,7 @@ XInternAtoms (
   1.183 +     xInternAtomReply rep;
   1.184 + 
   1.185 +     LockDisplay(dpy);
   1.186 +-    async_state.start_seq = dpy->request + 1;
   1.187 ++    async_state.start_seq = X_DPY_GET_REQUEST(dpy) + 1;
   1.188 +     async_state.atoms = atoms_return;
   1.189 +     async_state.names = names;
   1.190 +     async_state.count = count - 1;
   1.191 +@@ -266,7 +268,7 @@ XInternAtoms (
   1.192 + 					     &sig, &idx, &n))) {
   1.193 + 	    missed = i;
   1.194 + 	    atoms_return[i] = ~((Atom)idx);
   1.195 +-	    async_state.stop_seq = dpy->request;
   1.196 ++	    async_state.stop_seq = X_DPY_GET_REQUEST(dpy);
   1.197 + 	}
   1.198 +     }
   1.199 +     if (missed >= 0) {
   1.200 +diff --git a/src/OpenDis.c b/src/OpenDis.c
   1.201 +index 636860e..8272357 100644
   1.202 +--- a/src/OpenDis.c
   1.203 ++++ b/src/OpenDis.c
   1.204 +@@ -197,8 +197,8 @@ XOpenDisplay (
   1.205 + 	dpy->idlist_alloc = _XAllocIDs;
   1.206 + 	dpy->synchandler = NULL;
   1.207 + 	dpy->savedsynchandler = NULL;
   1.208 +-	dpy->request = 0;
   1.209 +-	dpy->last_request_read = 0;
   1.210 ++	X_DPY_SET_REQUEST(dpy, 0);
   1.211 ++	X_DPY_SET_LAST_REQUEST_READ(dpy, 0);
   1.212 + 	dpy->default_screen = iscreen;  /* Value returned by ConnectDisplay */
   1.213 + 	dpy->last_req = (char *)&_dummy_request;
   1.214 + 
   1.215 +diff --git a/src/PutImage.c b/src/PutImage.c
   1.216 +index de085bc..13cbba3 100644
   1.217 +--- a/src/PutImage.c
   1.218 ++++ b/src/PutImage.c
   1.219 +@@ -602,7 +602,7 @@ static int const HalfOrderWord[12] = {
   1.220 + 
   1.221 + #define UnGetReq(name)\
   1.222 +     dpy->bufptr -= SIZEOF(x##name##Req);\
   1.223 +-    dpy->request--
   1.224 ++    X_DPY_REQUEST_DECREMENT(dpy)
   1.225 + 
   1.226 + static void
   1.227 + SendXYImage(
   1.228 +diff --git a/src/XlibAsync.c b/src/XlibAsync.c
   1.229 +index eb2b819..d62000e 100644
   1.230 +--- a/src/XlibAsync.c
   1.231 ++++ b/src/XlibAsync.c
   1.232 +@@ -32,6 +32,18 @@ from The Open Group.
   1.233 + #include <X11/Xlibint.h>
   1.234 + #include <X11/Xos.h>
   1.235 + 
   1.236 ++/*
   1.237 ++ * Xlib's _XAsyncErrorState sequence number may wrap in 32bit
   1.238 ++ * and we cannot use 64bit as it's public API.
   1.239 ++ */
   1.240 ++#ifdef LONG64
   1.241 ++#define _XLIB_ASYNC_SEQUENCE_CMP(a,op,b)     ((a == 0) || (a op b))
   1.242 ++#else /* !LONG64 */
   1.243 ++#define _XLIB_ASYNC_SEQUENCE_CMP(a,op,b)     ((a == 0) || \
   1.244 ++                                              (((a op b) && (b - a op (UINT32_MAX >> 1))) || \
   1.245 ++                                               ((b op a) && ((UINT32_MAX >> 1) op a - b))))
   1.246 ++#endif /* !LONG64 */
   1.247 ++
   1.248 + /*ARGSUSED*/
   1.249 + Bool
   1.250 + _XAsyncErrorHandler(
   1.251 +@@ -51,10 +63,8 @@ _XAsyncErrorHandler(
   1.252 + 	 rep->error.majorCode == state->major_opcode) &&
   1.253 + 	(!state->minor_opcode ||
   1.254 + 	 rep->error.minorCode == state->minor_opcode) &&
   1.255 +-	(!state->min_sequence_number ||
   1.256 +-	 (state->min_sequence_number <= dpy->last_request_read)) &&
   1.257 +-	(!state->max_sequence_number ||
   1.258 +-	 (state->max_sequence_number >= dpy->last_request_read))) {
   1.259 ++	(_XLIB_ASYNC_SEQUENCE_CMP(state->min_sequence_number,<=,dpy->last_request_read)) &&
   1.260 ++	(_XLIB_ASYNC_SEQUENCE_CMP(state->max_sequence_number,>=,dpy->last_request_read))) {
   1.261 + 	state->last_error_received = rep->error.errorCode;
   1.262 + 	state->error_count++;
   1.263 + 	return True;
   1.264 +diff --git a/src/XlibInt.c b/src/XlibInt.c
   1.265 +index bbc5c82..7296948 100644
   1.266 +--- a/src/XlibInt.c
   1.267 ++++ b/src/XlibInt.c
   1.268 +@@ -167,8 +167,12 @@ void _XPollfdCacheDel(
   1.269 + 
   1.270 + static int sync_hazard(Display *dpy)
   1.271 + {
   1.272 +-    unsigned long span = dpy->request - dpy->last_request_read;
   1.273 +-    unsigned long hazard = min((dpy->bufmax - dpy->buffer) / SIZEOF(xReq), 65535 - 10);
   1.274 ++    /*
   1.275 ++     * "span" and "hazard" need to be signed such that the ">=" comparision
   1.276 ++     * works correctly in the case that hazard is greater than 65525
   1.277 ++     */
   1.278 ++    int64_t span = X_DPY_GET_REQUEST(dpy) - X_DPY_GET_LAST_REQUEST_READ(dpy);
   1.279 ++    int64_t hazard = min((dpy->bufmax - dpy->buffer) / SIZEOF(xReq), 65535 - 10);
   1.280 +     return span >= 65535 - hazard - 10;
   1.281 + }
   1.282 + 
   1.283 +@@ -194,7 +198,7 @@ void _XSeqSyncFunction(
   1.284 +     xGetInputFocusReply rep;
   1.285 +     register xReq *req;
   1.286 + 
   1.287 +-    if ((dpy->request - dpy->last_request_read) >= (65535 - BUFSIZE/SIZEOF(xReq))) {
   1.288 ++    if ((X_DPY_GET_REQUEST(dpy) - X_DPY_GET_LAST_REQUEST_READ(dpy)) >= (65535 - BUFSIZE/SIZEOF(xReq))) {
   1.289 + 	GetEmptyReq(GetInputFocus, req);
   1.290 + 	(void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
   1.291 + 	sync_while_locked(dpy);
   1.292 +@@ -276,9 +280,9 @@ _XSetLastRequestRead(
   1.293 +     register Display *dpy,
   1.294 +     register xGenericReply *rep)
   1.295 + {
   1.296 +-    register unsigned long	newseq, lastseq;
   1.297 ++    register uint64_t	newseq, lastseq;
   1.298 + 
   1.299 +-    lastseq = dpy->last_request_read;
   1.300 ++    lastseq = X_DPY_GET_LAST_REQUEST_READ(dpy);
   1.301 +     /*
   1.302 +      * KeymapNotify has no sequence number, but is always guaranteed
   1.303 +      * to immediately follow another event, except when generated via
   1.304 +@@ -287,20 +291,21 @@ _XSetLastRequestRead(
   1.305 +     if ((rep->type & 0x7f) == KeymapNotify)
   1.306 + 	return(lastseq);
   1.307 + 
   1.308 +-    newseq = (lastseq & ~((unsigned long)0xffff)) | rep->sequenceNumber;
   1.309 ++    newseq = (lastseq & ~((uint64_t)0xffff)) | rep->sequenceNumber;
   1.310 + 
   1.311 +     if (newseq < lastseq) {
   1.312 + 	newseq += 0x10000;
   1.313 +-	if (newseq > dpy->request) {
   1.314 ++	if (newseq > X_DPY_GET_REQUEST(dpy)) {
   1.315 + 	    (void) fprintf (stderr,
   1.316 +-	    "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n",
   1.317 +-			    newseq, dpy->request,
   1.318 ++	    "Xlib: sequence lost (0x%llx > 0x%llx) in reply type 0x%x!\n",
   1.319 ++			    (unsigned long long)newseq,
   1.320 ++			    (unsigned long long)(X_DPY_GET_REQUEST(dpy)),
   1.321 + 			    (unsigned int) rep->type);
   1.322 + 	    newseq -= 0x10000;
   1.323 + 	}
   1.324 +     }
   1.325 + 
   1.326 +-    dpy->last_request_read = newseq;
   1.327 ++    X_DPY_SET_LAST_REQUEST_READ(dpy, newseq);
   1.328 +     return(newseq);
   1.329 + }
   1.330 + 
   1.331 +@@ -1363,10 +1368,10 @@ static int _XPrintDefaultError(
   1.332 + 			  mesg, BUFSIZ);
   1.333 +     fputs("  ", fp);
   1.334 +     (void) fprintf(fp, mesg, event->serial);
   1.335 +-    XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
   1.336 ++    XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%lld",
   1.337 + 			  mesg, BUFSIZ);
   1.338 +     fputs("\n  ", fp);
   1.339 +-    (void) fprintf(fp, mesg, dpy->request);
   1.340 ++    (void) fprintf(fp, mesg, (unsigned long long)(X_DPY_GET_REQUEST(dpy)));
   1.341 +     fputs("\n", fp);
   1.342 +     if (event->error_code == BadImplementation) return 0;
   1.343 +     return 1;
   1.344 +@@ -1720,7 +1725,7 @@ void *_XGetRequest(Display *dpy, CARD8 type, size_t len)
   1.345 +     req->reqType = type;
   1.346 +     req->length = len / 4;
   1.347 +     dpy->bufptr += len;
   1.348 +-    dpy->request++;
   1.349 ++    X_DPY_REQUEST_INCREMENT(dpy);
   1.350 +     return req;
   1.351 + }
   1.352 + 
   1.353 +diff --git a/src/Xxcbint.h b/src/Xxcbint.h
   1.354 +index bf41c23..20a6386 100644
   1.355 +--- a/src/Xxcbint.h
   1.356 ++++ b/src/Xxcbint.h
   1.357 +@@ -13,12 +13,12 @@
   1.358 + #include <X11/Xlib-xcb.h>
   1.359 + #include "locking.h"
   1.360 + 
   1.361 +-#define XLIB_SEQUENCE_COMPARE(a,op,b)	(((long) (a) - (long) (b)) op 0)
   1.362 ++#define XLIB_SEQUENCE_COMPARE(a,op,b)	(((int64_t) (a) - (int64_t) (b)) op 0)
   1.363 + 
   1.364 + typedef struct PendingRequest PendingRequest;
   1.365 + struct PendingRequest {
   1.366 + 	PendingRequest *next;
   1.367 +-	unsigned long sequence;
   1.368 ++	uint64_t sequence;
   1.369 + 	unsigned reply_waiter;
   1.370 + };
   1.371 + 
   1.372 +diff --git a/src/xcb_io.c b/src/xcb_io.c
   1.373 +index 5987329..bd26a62 100644
   1.374 +--- a/src/xcb_io.c
   1.375 ++++ b/src/xcb_io.c
   1.376 +@@ -68,22 +68,8 @@ static void require_socket(Display *dpy)
   1.377 + 		if(!xcb_take_socket(dpy->xcb->connection, return_socket, dpy,
   1.378 + 		                    flags, &sent))
   1.379 + 			_XIOError(dpy);
   1.380 +-		/* Xlib uses unsigned long for sequence numbers.  XCB
   1.381 +-		 * uses 64-bit internally, but currently exposes an
   1.382 +-		 * unsigned int API.  If these differ, Xlib cannot track
   1.383 +-		 * the full 64-bit sequence number if 32-bit wrap
   1.384 +-		 * happens while Xlib does not own the socket.  A
   1.385 +-		 * complete fix would be to make XCB's public API use
   1.386 +-		 * 64-bit sequence numbers. */
   1.387 +-		if (sizeof(unsigned long) > sizeof(unsigned int) &&
   1.388 +-		    dpy->xcb->event_owner == XlibOwnsEventQueue &&
   1.389 +-		    (sent - dpy->last_request_read >= (UINT64_C(1) << 32))) {
   1.390 +-			throw_thread_fail_assert("Sequence number wrapped "
   1.391 +-			                         "beyond 32 bits while Xlib "
   1.392 +-						 "did not own the socket",
   1.393 +-			                         xcb_xlib_seq_number_wrapped);
   1.394 +-		}
   1.395 +-		dpy->xcb->last_flushed = dpy->request = sent;
   1.396 ++		dpy->xcb->last_flushed = sent;
   1.397 ++		X_DPY_SET_REQUEST(dpy, sent);
   1.398 + 		dpy->bufmax = dpy->xcb->real_bufmax;
   1.399 + 	}
   1.400 + }
   1.401 +@@ -145,7 +131,7 @@ static void check_internal_connections(Display *dpy)
   1.402 + 		}
   1.403 + }
   1.404 + 
   1.405 +-static PendingRequest *append_pending_request(Display *dpy, unsigned long sequence)
   1.406 ++static PendingRequest *append_pending_request(Display *dpy, uint64_t sequence)
   1.407 + {
   1.408 + 	PendingRequest *node = malloc(sizeof(PendingRequest));
   1.409 + 	assert(node);
   1.410 +@@ -214,14 +200,13 @@ static int handle_error(Display *dpy, xError *err, Bool in_XReply)
   1.411 + 	return 0;
   1.412 + }
   1.413 + 
   1.414 +-/* Widen a 32-bit sequence number into a native-word-size (unsigned long)
   1.415 +- * sequence number.  Treating the comparison as a 1 and shifting it avoids a
   1.416 +- * conditional branch, and shifting by 16 twice avoids a compiler warning when
   1.417 +- * sizeof(unsigned long) == 4. */
   1.418 +-static void widen(unsigned long *wide, unsigned int narrow)
   1.419 ++/* Widen a 32-bit sequence number into a 64bit (uint64_t) sequence number.
   1.420 ++ * Treating the comparison as a 1 and shifting it avoids a conditional branch.
   1.421 ++ */
   1.422 ++static void widen(uint64_t *wide, unsigned int narrow)
   1.423 + {
   1.424 +-	unsigned long new = (*wide & ~0xFFFFFFFFUL) | narrow;
   1.425 +-	*wide = new + ((unsigned long) (new < *wide) << 16 << 16);
   1.426 ++	uint64_t new = (*wide & ~((uint64_t)0xFFFFFFFFUL)) | narrow;
   1.427 ++	*wide = new + (((uint64_t)(new < *wide)) << 32);
   1.428 + }
   1.429 + 
   1.430 + /* Thread-safety rules:
   1.431 +@@ -260,20 +245,20 @@ static xcb_generic_reply_t *poll_for_event(Display *dpy)
   1.432 + 	{
   1.433 + 		PendingRequest *req = dpy->xcb->pending_requests;
   1.434 + 		xcb_generic_event_t *event = dpy->xcb->next_event;
   1.435 +-		unsigned long event_sequence = dpy->last_request_read;
   1.436 ++		uint64_t event_sequence = X_DPY_GET_LAST_REQUEST_READ(dpy);
   1.437 + 		widen(&event_sequence, event->full_sequence);
   1.438 + 		if(!req || XLIB_SEQUENCE_COMPARE(event_sequence, <, req->sequence)
   1.439 + 		        || (event->response_type != X_Error && event_sequence == req->sequence))
   1.440 + 		{
   1.441 +-			if (XLIB_SEQUENCE_COMPARE(event_sequence, >,
   1.442 +-			                          dpy->request))
   1.443 ++			uint64_t request = X_DPY_GET_REQUEST(dpy);
   1.444 ++			if (XLIB_SEQUENCE_COMPARE(event_sequence, >, request))
   1.445 + 			{
   1.446 + 				throw_thread_fail_assert("Unknown sequence "
   1.447 + 				                         "number while "
   1.448 + 							 "processing queue",
   1.449 + 				                xcb_xlib_threads_sequence_lost);
   1.450 + 			}
   1.451 +-			dpy->last_request_read = event_sequence;
   1.452 ++			X_DPY_SET_LAST_REQUEST_READ(dpy, event_sequence);
   1.453 + 			dpy->xcb->next_event = NULL;
   1.454 + 			return (xcb_generic_reply_t *) event;
   1.455 + 		}
   1.456 +@@ -289,15 +274,16 @@ static xcb_generic_reply_t *poll_for_response(Display *dpy)
   1.457 + 	while(!(response = poll_for_event(dpy)) &&
   1.458 + 	      (req = dpy->xcb->pending_requests) &&
   1.459 + 	      !req->reply_waiter &&
   1.460 +-	      xcb_poll_for_reply(dpy->xcb->connection, req->sequence, &response, &error))
   1.461 ++	      xcb_poll_for_reply64(dpy->xcb->connection, req->sequence, &response, &error))
   1.462 + 	{
   1.463 +-		if(XLIB_SEQUENCE_COMPARE(req->sequence, >, dpy->request))
   1.464 ++		uint64_t request = X_DPY_GET_REQUEST(dpy);
   1.465 ++		if(XLIB_SEQUENCE_COMPARE(req->sequence, >, request))
   1.466 + 		{
   1.467 + 			throw_thread_fail_assert("Unknown sequence number "
   1.468 + 			                         "while awaiting reply",
   1.469 + 			                        xcb_xlib_threads_sequence_lost);
   1.470 + 		}
   1.471 +-		dpy->last_request_read = req->sequence;
   1.472 ++		X_DPY_SET_LAST_REQUEST_READ(dpy, req->sequence);
   1.473 + 		if(response)
   1.474 + 			break;
   1.475 + 		dequeue_pending_request(dpy, req);
   1.476 +@@ -456,6 +442,7 @@ void _XSend(Display *dpy, const char *data, long size)
   1.477 + 	static char const pad[3];
   1.478 + 	struct iovec vec[3];
   1.479 + 	uint64_t requests;
   1.480 ++	uint64_t dpy_request;
   1.481 + 	_XExtension *ext;
   1.482 + 	xcb_connection_t *c = dpy->xcb->connection;
   1.483 + 	if(dpy->flags & XlibDisplayIOError)
   1.484 +@@ -464,6 +451,10 @@ void _XSend(Display *dpy, const char *data, long size)
   1.485 + 	if(dpy->bufptr == dpy->buffer && !size)
   1.486 + 		return;
   1.487 + 
   1.488 ++	/* append_pending_request does not alter the dpy request number
   1.489 ++	 * therefore we can get it outside of the loop and the if
   1.490 ++	 */
   1.491 ++	dpy_request = X_DPY_GET_REQUEST(dpy);
   1.492 + 	/* iff we asked XCB to set aside errors, we must pick those up
   1.493 + 	 * eventually. iff there are async handlers, we may have just
   1.494 + 	 * issued requests that will generate replies. in either case,
   1.495 +@@ -471,11 +462,11 @@ void _XSend(Display *dpy, const char *data, long size)
   1.496 + 	if(dpy->xcb->event_owner != XlibOwnsEventQueue || dpy->async_handlers)
   1.497 + 	{
   1.498 + 		uint64_t sequence;
   1.499 +-		for(sequence = dpy->xcb->last_flushed + 1; sequence <= dpy->request; ++sequence)
   1.500 ++		for(sequence = dpy->xcb->last_flushed + 1; sequence <= dpy_request; ++sequence)
   1.501 + 			append_pending_request(dpy, sequence);
   1.502 + 	}
   1.503 +-	requests = dpy->request - dpy->xcb->last_flushed;
   1.504 +-	dpy->xcb->last_flushed = dpy->request;
   1.505 ++	requests = dpy_request - dpy->xcb->last_flushed;
   1.506 ++	dpy->xcb->last_flushed = dpy_request;
   1.507 + 
   1.508 + 	vec[0].iov_base = dpy->buffer;
   1.509 + 	vec[0].iov_len = dpy->bufptr - dpy->buffer;
   1.510 +@@ -570,6 +561,7 @@ Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard)
   1.511 + 	xcb_connection_t *c = dpy->xcb->connection;
   1.512 + 	char *reply;
   1.513 + 	PendingRequest *current;
   1.514 ++	uint64_t dpy_request;
   1.515 + 
   1.516 + 	if (dpy->xcb->reply_data)
   1.517 + 		throw_extlib_fail_assert("Extra reply data still left in queue",
   1.518 +@@ -579,10 +571,12 @@ Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard)
   1.519 + 		return 0;
   1.520 + 
   1.521 + 	_XSend(dpy, NULL, 0);
   1.522 +-	if(dpy->xcb->pending_requests_tail && dpy->xcb->pending_requests_tail->sequence == dpy->request)
   1.523 ++	dpy_request = X_DPY_GET_REQUEST(dpy);
   1.524 ++	if(dpy->xcb->pending_requests_tail
   1.525 ++	   && dpy->xcb->pending_requests_tail->sequence == dpy_request)
   1.526 + 		current = dpy->xcb->pending_requests_tail;
   1.527 + 	else
   1.528 +-		current = append_pending_request(dpy, dpy->request);
   1.529 ++		current = append_pending_request(dpy, dpy_request);
   1.530 + 	/* Don't let any other thread get this reply. */
   1.531 + 	current->reply_waiter = 1;
   1.532 + 
   1.533 +@@ -599,9 +593,9 @@ Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard)
   1.534 + 		}
   1.535 + 		req->reply_waiter = 1;
   1.536 + 		UnlockDisplay(dpy);
   1.537 +-		response = xcb_wait_for_reply(c, req->sequence, &error);
   1.538 ++		response = xcb_wait_for_reply64(c, req->sequence, &error);
   1.539 + 		/* Any user locks on another thread must have been taken
   1.540 +-		 * while we slept in xcb_wait_for_reply. Classic Xlib
   1.541 ++		 * while we slept in xcb_wait_for_reply64. Classic Xlib
   1.542 + 		 * ignored those user locks in this case, so we do too. */
   1.543 + 		InternalLockDisplay(dpy, /* ignore user locks */ 1);
   1.544 + 
   1.545 +@@ -629,12 +623,13 @@ Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard)
   1.546 + 
   1.547 + 		req->reply_waiter = 0;
   1.548 + 		ConditionBroadcast(dpy, dpy->xcb->reply_notify);
   1.549 +-		if(XLIB_SEQUENCE_COMPARE(req->sequence, >, dpy->request)) {
   1.550 ++		dpy_request = X_DPY_GET_REQUEST(dpy);
   1.551 ++		if(XLIB_SEQUENCE_COMPARE(req->sequence, >, dpy_request)) {
   1.552 + 			throw_thread_fail_assert("Unknown sequence number "
   1.553 + 			                         "while processing reply",
   1.554 + 			                        xcb_xlib_threads_sequence_lost);
   1.555 + 		}
   1.556 +-		dpy->last_request_read = req->sequence;
   1.557 ++		X_DPY_SET_LAST_REQUEST_READ(dpy, req->sequence);
   1.558 + 		if(!response)
   1.559 + 			dequeue_pending_request(dpy, req);
   1.560 + 
   1.561 +@@ -654,9 +649,10 @@ Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard)
   1.562 + 	if(dpy->xcb->next_event && dpy->xcb->next_event->response_type == X_Error)
   1.563 + 	{
   1.564 + 		xcb_generic_event_t *event = dpy->xcb->next_event;
   1.565 +-		unsigned long event_sequence = dpy->last_request_read;
   1.566 ++		uint64_t last_request_read = X_DPY_GET_LAST_REQUEST_READ(dpy);
   1.567 ++		uint64_t event_sequence = last_request_read;
   1.568 + 		widen(&event_sequence, event->full_sequence);
   1.569 +-		if(event_sequence == dpy->last_request_read)
   1.570 ++		if(event_sequence == last_request_read)
   1.571 + 		{
   1.572 + 			error = (xcb_generic_error_t *) event;
   1.573 + 			dpy->xcb->next_event = NULL;
   1.574 +-- 
   1.575 +cgit v0.10.2
   1.576 +
   1.577 +--- a/include/X11/Xlibint.h.orig2	2017-03-11 09:35:16.131106050 -0800
   1.578 ++++ b/include/X11/Xlibint.h	2017-03-11 09:34:10.010324406 -0800
   1.579 +@@ -38,6 +38,7 @@
   1.580 +  *	Warning, there be dragons here....
   1.581 +  */
   1.582 + 
   1.583 ++#include <stdint.h>
   1.584 + #include <X11/Xlib.h>
   1.585 + #include <X11/Xproto.h>		/* to declare xEvent */
   1.586 + #include <X11/XlibConf.h>	/* for configured options like XTHREADS */
   1.587 +@@ -205,6 +206,10 @@
   1.588 + 		XGenericEventCookie *	/* in */,
   1.589 + 		XGenericEventCookie *   /* out*/);
   1.590 + 	void *cookiejar;  /* cookie events returned but not claimed */
   1.591 ++#ifndef LONG64
   1.592 ++	unsigned long last_request_read_upper32bit;
   1.593 ++	unsigned long request_upper32bit;
   1.594 ++#endif
   1.595 + };
   1.596 + 
   1.597 + #if defined(XTHREADS) && defined(SUNSOFT)
   1.598 +@@ -212,7 +217,115 @@
   1.599 + #endif /* XTHREADS && SUNSOFT */
   1.600 + 
   1.601 + #define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)
   1.602 ++/*
   1.603 ++ * access "last_request_read" and "request" with 64bit
   1.604 ++ * warning: the value argument of the SET-macros must not
   1.605 ++ * have any side-effects because it may get called twice.
   1.606 ++ */
   1.607 ++#ifndef LONG64
   1.608 ++/* accessors for 32-bit unsigned long */
   1.609 + 
   1.610 ++#define X_DPY_GET_REQUEST(dpy) \
   1.611 ++    ( \
   1.612 ++        ((uint64_t)(((struct _XDisplay*)dpy)->request)) \
   1.613 ++	+ (((uint64_t)(((struct _XDisplay*)dpy)->request_upper32bit)) << 32) \
   1.614 ++    )
   1.615 ++
   1.616 ++#define X_DPY_SET_REQUEST(dpy, value) \
   1.617 ++    ( \
   1.618 ++        (((struct _XDisplay*)dpy)->request = \
   1.619 ++            (value) & 0xFFFFFFFFUL), \
   1.620 ++        (((struct _XDisplay*)dpy)->request_upper32bit = \
   1.621 ++            ((uint64_t)(value)) >> 32), \
   1.622 ++	(void)0 /* don't use the result */ \
   1.623 ++    )
   1.624 ++
   1.625 ++#define X_DPY_GET_LAST_REQUEST_READ(dpy) \
   1.626 ++    ( \
   1.627 ++        ((uint64_t)(((struct _XDisplay*)dpy)->last_request_read)) \
   1.628 ++        + ( \
   1.629 ++            ((uint64_t)( \
   1.630 ++                ((struct _XDisplay*)dpy)->last_request_read_upper32bit \
   1.631 ++            )) << 32 \
   1.632 ++        ) \
   1.633 ++    )
   1.634 ++
   1.635 ++#define X_DPY_SET_LAST_REQUEST_READ(dpy, value) \
   1.636 ++    ( \
   1.637 ++        (((struct _XDisplay*)dpy)->last_request_read = \
   1.638 ++            (value) & 0xFFFFFFFFUL), \
   1.639 ++        (((struct _XDisplay*)dpy)->last_request_read_upper32bit = \
   1.640 ++            ((uint64_t)(value)) >> 32), \
   1.641 ++	(void)0 /* don't use the result */ \
   1.642 ++    )
   1.643 ++
   1.644 ++/*
   1.645 ++ * widen a 32-bit sequence number to a 64 sequence number.
   1.646 ++ * This macro makes the following assumptions:
   1.647 ++ * - ulseq refers to a sequence that has already been sent
   1.648 ++ * - ulseq means the most recent possible sequence number
   1.649 ++ *   with these lower 32 bits.
   1.650 ++ *
   1.651 ++ * The following optimization is used:
   1.652 ++ * The comparison result is taken a 0 or 1 to avoid a branch.
   1.653 ++ */
   1.654 ++#define X_DPY_WIDEN_UNSIGNED_LONG_SEQ(dpy, ulseq) \
   1.655 ++    ( \
   1.656 ++        ((uint64_t)ulseq) \
   1.657 ++        + \
   1.658 ++        (( \
   1.659 ++            ((uint64_t)(((struct _XDisplay*)dpy)->request_upper32bit)) \
   1.660 ++            - (uint64_t)( \
   1.661 ++                (ulseq) > (((struct _XDisplay*)dpy)->request) \
   1.662 ++	    ) \
   1.663 ++        ) << 32) \
   1.664 ++    )
   1.665 ++
   1.666 ++#define X_DPY_REQUEST_INCREMENT(dpy) \
   1.667 ++    ( \
   1.668 ++        ((struct _XDisplay*)dpy)->request++, \
   1.669 ++        ( \
   1.670 ++            (((struct _XDisplay*)dpy)->request == 0) ? ( \
   1.671 ++                ((struct _XDisplay*)dpy)->request_upper32bit++ \
   1.672 ++	    ) : 0 \
   1.673 ++        ), \
   1.674 ++	(void)0 /* don't use the result */ \
   1.675 ++    )
   1.676 ++
   1.677 ++
   1.678 ++#define X_DPY_REQUEST_DECREMENT(dpy) \
   1.679 ++    ( \
   1.680 ++	( \
   1.681 ++            (((struct _XDisplay*)dpy)->request == 0) ? (\
   1.682 ++                ((struct _XDisplay*)dpy)->request--, /* wrap */ \
   1.683 ++                ((struct _XDisplay*)dpy)->request_upper32bit-- \
   1.684 ++            ) : ( \
   1.685 ++                ((struct _XDisplay*)dpy)->request-- \
   1.686 ++            ) \
   1.687 ++	), \
   1.688 ++	(void)0 /* don't use the result */ \
   1.689 ++    )
   1.690 ++
   1.691 ++#else
   1.692 ++/* accessors for 64-bit unsigned long */
   1.693 ++#define X_DPY_GET_REQUEST(dpy) \
   1.694 ++    (((struct _XDisplay*)dpy)->request)
   1.695 ++#define X_DPY_SET_REQUEST(dpy, value) \
   1.696 ++    ((struct _XDisplay*)dpy)->request = (value)
   1.697 ++
   1.698 ++#define X_DPY_GET_LAST_REQUEST_READ(dpy) \
   1.699 ++    (((struct _XDisplay*)dpy)->last_request_read)
   1.700 ++#define X_DPY_SET_LAST_REQUEST_READ(dpy, value) \
   1.701 ++    ((struct _XDisplay*)dpy)->last_request_read = (value)
   1.702 ++
   1.703 ++#define X_DPY_WIDEN_UNSIGNED_LONG_SEQ(dpy, ulseq) ulseq
   1.704 ++
   1.705 ++#define X_DPY_REQUEST_INCREMENT(dpy) ((struct _XDisplay*)dpy)->request++
   1.706 ++#define X_DPY_REQUEST_DECREMENT(dpy) ((struct _XDisplay*)dpy)->request--
   1.707 ++#endif
   1.708 ++
   1.709 ++
   1.710 ++
   1.711 + #ifndef _XEVENT_
   1.712 + /*
   1.713 +  * _QEvent datatype for use in input queueing.
   1.714 +@@ -677,6 +790,11 @@
   1.715 +     XPointer data;
   1.716 + } _XAsyncHandler;
   1.717 + 
   1.718 ++/*
   1.719 ++ * This struct is part of the ABI and is defined by value
   1.720 ++ * in user-code. This means that we cannot make
   1.721 ++ * the sequence-numbers 64bit.
   1.722 ++ */
   1.723 + typedef struct _XAsyncEState {
   1.724 +     unsigned long min_sequence_number;
   1.725 +     unsigned long max_sequence_number;
     2.1 --- a/open-src/lib/libX11/Makefile	Fri Apr 07 15:26:24 2017 -0700
     2.2 +++ b/open-src/lib/libX11/Makefile	Wed Apr 12 06:57:07 2017 +0000
     2.3 @@ -1,6 +1,6 @@
     2.4  ###############################################################################
     2.5  #
     2.6 -# Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
     2.7 +# Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
     2.8  #
     2.9  # Permission is hereby granted, free of charge, to any person obtaining a
    2.10  # copy of this software and associated documentation files (the "Software"),
    2.11 @@ -67,7 +67,8 @@
    2.12  	locale-zh_CN.gb18030.patch,-p1 \
    2.13  	locale-zh_HK.UTF-8.patch,-p1 \
    2.14  	locale-zh_TW.UTF-8.patch,-p1 \
    2.15 -	locale-zh_TW.patch,-p1
    2.16 +	locale-zh_TW.patch,-p1 \
    2.17 +	19154747.patch,-p1
    2.18  
    2.19  # Library name (used for specfiles/mapfiles)
    2.20  LIBNAME=X11
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/open-src/lib/libxcb/19154747.patch	Wed Apr 12 06:57:07 2017 +0000
     3.3 @@ -0,0 +1,235 @@
     3.4 +From 0ba6fe9b4eaa70383cd2ee066dfb3f1e67efeb83 Mon Sep 17 00:00:00 2001
     3.5 +From: Christian Linhart <chris@demorecorder.com>
     3.6 +Date: Wed, 29 Apr 2015 09:11:37 +0200
     3.7 +Subject: expose 64-bit sequence numbers for XLib
     3.8 +
     3.9 +While XCB uses 64-bit sequence number internally, it only exposes
    3.10 +"unsigned int" so that, on 32-bit architecture, Xlib based applications
    3.11 +may see their sequence number wrap which causes the connection to the X
    3.12 +server to be lost.
    3.13 +
    3.14 +Expose 64-bit sequence number from XCB API so that Xlib and others can
    3.15 +use it even on 32-bit environment.
    3.16 +
    3.17 +This implies the following API addition:
    3.18 +
    3.19 +  xcb_send_request64()
    3.20 +  xcb_discard_reply64()
    3.21 +  xcb_wait_for_reply64()
    3.22 +  xcb_poll_for_reply64()
    3.23 +
    3.24 +Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=71338
    3.25 +
    3.26 +Reviewed-by: Uli Schlachter <psychon@znc.in>
    3.27 +Signed-off-by: Christian Linhart <chris@demorecorder.com>
    3.28 +Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
    3.29 +
    3.30 +diff --git a/src/xcb.h b/src/xcb.h
    3.31 +index 23fe74e..86eb1bc 100644
    3.32 +--- a/src/xcb.h
    3.33 ++++ b/src/xcb.h
    3.34 +@@ -378,6 +378,26 @@ xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t co
    3.35 +  */
    3.36 + void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence);
    3.37 + 
    3.38 ++/**
    3.39 ++ * @brief Discards the reply for a request, given by a 64bit sequence number
    3.40 ++ * @param c: The connection to the X server.
    3.41 ++ * @param sequence: 64-bit sequence number as returned by xcb_send_request64().
    3.42 ++ *
    3.43 ++ * Discards the reply for a request. Additionally, any error generated
    3.44 ++ * by the request is also discarded (unless it was an _unchecked request
    3.45 ++ * and the error has already arrived).
    3.46 ++ *
    3.47 ++ * This function will not block even if the reply is not yet available.
    3.48 ++ *
    3.49 ++ * Note that the sequence really does have to come from xcb_send_request64();
    3.50 ++ * the cookie sequence number is defined as "unsigned" int and therefore
    3.51 ++ * not 64-bit on all platforms.
    3.52 ++ * This function is not designed to operate on socket-handoff replies.
    3.53 ++ *
    3.54 ++ * Unlike its xcb_discard_reply() counterpart, the given sequence number is not
    3.55 ++ * automatically "widened" to 64-bit.
    3.56 ++ */
    3.57 ++void xcb_discard_reply64(xcb_connection_t *c, uint64_t sequence);
    3.58 + 
    3.59 + /* xcb_ext.c */
    3.60 + 
    3.61 +diff --git a/src/xcb_in.c b/src/xcb_in.c
    3.62 +index ad870c1..623a0a8 100644
    3.63 +--- a/src/xcb_in.c
    3.64 ++++ b/src/xcb_in.c
    3.65 +@@ -523,6 +523,20 @@ void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_
    3.66 +     return ret;
    3.67 + }
    3.68 + 
    3.69 ++void *xcb_wait_for_reply64(xcb_connection_t *c, uint64_t request, xcb_generic_error_t **e)
    3.70 ++{
    3.71 ++    void *ret;
    3.72 ++    if(e)
    3.73 ++        *e = 0;
    3.74 ++    if(c->has_error)
    3.75 ++        return 0;
    3.76 ++
    3.77 ++    pthread_mutex_lock(&c->iolock);
    3.78 ++    ret = wait_for_reply(c, request, e);
    3.79 ++    pthread_mutex_unlock(&c->iolock);
    3.80 ++    return ret;
    3.81 ++}
    3.82 ++
    3.83 + int *xcb_get_reply_fds(xcb_connection_t *c, void *reply, size_t reply_size)
    3.84 + {
    3.85 +     return (int *) (&((char *) reply)[reply_size]);
    3.86 +@@ -595,6 +609,20 @@ void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence)
    3.87 +     pthread_mutex_unlock(&c->iolock);
    3.88 + }
    3.89 + 
    3.90 ++void xcb_discard_reply64(xcb_connection_t *c, uint64_t sequence)
    3.91 ++{
    3.92 ++    if(c->has_error)
    3.93 ++        return;
    3.94 ++
    3.95 ++    /* If an error occurred when issuing the request, fail immediately. */
    3.96 ++    if(!sequence)
    3.97 ++        return;
    3.98 ++
    3.99 ++    pthread_mutex_lock(&c->iolock);
   3.100 ++    discard_reply(c, sequence);
   3.101 ++    pthread_mutex_unlock(&c->iolock);
   3.102 ++}
   3.103 ++
   3.104 + int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error)
   3.105 + {
   3.106 +     int ret;
   3.107 +@@ -612,6 +640,23 @@ int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply,
   3.108 +     return ret;
   3.109 + }
   3.110 + 
   3.111 ++int xcb_poll_for_reply64(xcb_connection_t *c, uint64_t request, void **reply, xcb_generic_error_t **error)
   3.112 ++{
   3.113 ++    int ret;
   3.114 ++    if(c->has_error)
   3.115 ++    {
   3.116 ++        *reply = 0;
   3.117 ++        if(error)
   3.118 ++            *error = 0;
   3.119 ++        return 1; /* would not block */
   3.120 ++    }
   3.121 ++    assert(reply != 0);
   3.122 ++    pthread_mutex_lock(&c->iolock);
   3.123 ++    ret = poll_for_reply(c, request, reply, error);
   3.124 ++    pthread_mutex_unlock(&c->iolock);
   3.125 ++    return ret;
   3.126 ++}
   3.127 ++
   3.128 + xcb_generic_event_t *xcb_wait_for_event(xcb_connection_t *c)
   3.129 + {
   3.130 +     xcb_generic_event_t *ret;
   3.131 +diff --git a/src/xcb_out.c b/src/xcb_out.c
   3.132 +index dc42954..8cc5be8 100644
   3.133 +--- a/src/xcb_out.c
   3.134 ++++ b/src/xcb_out.c
   3.135 +@@ -177,7 +177,7 @@ uint32_t xcb_get_maximum_request_length(xcb_connection_t *c)
   3.136 +     return c->out.maximum_request_length.value;
   3.137 + }
   3.138 + 
   3.139 +-unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *req)
   3.140 ++uint64_t xcb_send_request64(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *req)
   3.141 + {
   3.142 +     uint64_t request;
   3.143 +     uint32_t prefix[2];
   3.144 +@@ -286,6 +286,12 @@ unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vect
   3.145 +     return request;
   3.146 + }
   3.147 + 
   3.148 ++/* request number are actually uint64_t internally but keep API compat with unsigned int */
   3.149 ++unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *req)
   3.150 ++{
   3.151 ++    return xcb_send_request64(c, flags, vector, req);
   3.152 ++}
   3.153 ++
   3.154 + void
   3.155 + xcb_send_fd(xcb_connection_t *c, int fd)
   3.156 + {
   3.157 +diff --git a/src/xcbext.h b/src/xcbext.h
   3.158 +index 7587513..b2575f7 100644
   3.159 +--- a/src/xcbext.h
   3.160 ++++ b/src/xcbext.h
   3.161 +@@ -83,6 +83,30 @@ enum xcb_send_request_flags_t {
   3.162 + unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
   3.163 + 
   3.164 + /**
   3.165 ++ * @brief Send a request to the server, with 64-bit sequence number returned.
   3.166 ++ * @param c: The connection to the X server.
   3.167 ++ * @param flags: A combination of flags from the xcb_send_request_flags_t enumeration.
   3.168 ++ * @param vector: Data to send; must have two iovecs before start for internal use.
   3.169 ++ * @param request: Information about the request to be sent.
   3.170 ++ * @return The request's sequence number on success, 0 otherwise.
   3.171 ++ *
   3.172 ++ * This function sends a new request to the X server. The data of the request is
   3.173 ++ * given as an array of @c iovecs in the @p vector argument. The length of that
   3.174 ++ * array and the neccessary management information are given in the @p request
   3.175 ++ * argument.
   3.176 ++ *
   3.177 ++ * When this function returns, the request might or might not be sent already.
   3.178 ++ * Use xcb_flush() to make sure that it really was sent.
   3.179 ++ *
   3.180 ++ * Please note that this function is not the prefered way for sending requests.
   3.181 ++ * It's better to use the generated wrapper functions.
   3.182 ++ *
   3.183 ++ * Please note that xcb might use index -1 and -2 of the @p vector array internally,
   3.184 ++ * so they must be valid!
   3.185 ++ */
   3.186 ++uint64_t xcb_send_request64(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
   3.187 ++
   3.188 ++/**
   3.189 +  * @brief Send a file descriptor to the server in the next call to xcb_send_request.
   3.190 +  * @param c: The connection to the X server.
   3.191 +  * @param fd: The file descriptor to send.
   3.192 +@@ -162,6 +186,21 @@ int xcb_writev(xcb_connection_t *c, struct iovec *vector, int count, uint64_t re
   3.193 + void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_error_t **e);
   3.194 + 
   3.195 + /**
   3.196 ++ * @brief Wait for the reply of a given request, with 64-bit sequence number
   3.197 ++ * @param c: The connection to the X server.
   3.198 ++ * @param request: 64-bit sequence number of the request as returned by xcb_send_request64().
   3.199 ++ * @param e: Location to store errors in, or NULL. Ignored for unchecked requests.
   3.200 ++ *
   3.201 ++ * Returns the reply to the given request or returns null in the event of
   3.202 ++ * errors. Blocks until the reply or error for the request arrives, or an I/O
   3.203 ++ * error occurs.
   3.204 ++ *
   3.205 ++ * Unlike its xcb_wait_for_reply() counterpart, the given sequence number is not
   3.206 ++ * automatically "widened" to 64-bit.
   3.207 ++ */
   3.208 ++void *xcb_wait_for_reply64(xcb_connection_t *c, uint64_t request, xcb_generic_error_t **e);
   3.209 ++
   3.210 ++/**
   3.211 +  * @brief Poll for the reply of a given request.
   3.212 +  * @param c: The connection to the X server.
   3.213 +  * @param request: Sequence number of the request as returned by xcb_send_request().
   3.214 +@@ -174,6 +213,21 @@ void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_
   3.215 + int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error);
   3.216 + 
   3.217 + /**
   3.218 ++ * @brief Poll for the reply of a given request, with 64-bit sequence number.
   3.219 ++ * @param c: The connection to the X server.
   3.220 ++ * @param request: 64-bit sequence number of the request as returned by xcb_send_request().
   3.221 ++ * @param reply: Location to store the reply in, must not be NULL.
   3.222 ++ * @param e: Location to store errors in, or NULL. Ignored for unchecked requests.
   3.223 ++ * @return 1 when the reply to the request was returned, else 0.
   3.224 ++ *
   3.225 ++ * Checks if the reply to the given request already received. Does not block.
   3.226 ++ *
   3.227 ++ * Unlike its xcb_poll_for_reply() counterpart, the given sequence number is not
   3.228 ++ * automatically "widened" to 64-bit.
   3.229 ++ */
   3.230 ++int xcb_poll_for_reply64(xcb_connection_t *c, uint64_t request, void **reply, xcb_generic_error_t **error);
   3.231 ++
   3.232 ++/**
   3.233 +  * @brief Don't use this, only needed by the generated code.
   3.234 +  * @param c: The connection to the X server.
   3.235 +  * @param reply: A reply that was received from the server
   3.236 +-- 
   3.237 +cgit v0.10.2
   3.238 +
     4.1 --- a/open-src/lib/libxcb/Makefile	Fri Apr 07 15:26:24 2017 -0700
     4.2 +++ b/open-src/lib/libxcb/Makefile	Wed Apr 12 06:57:07 2017 +0000
     4.3 @@ -2,7 +2,7 @@
     4.4  #
     4.5  # xcb - Lighter weight X11 client libraries
     4.6  #
     4.7 -# Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
     4.8 +# Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
     4.9  #
    4.10  # Permission is hereby granted, free of charge, to any person obtaining a
    4.11  # copy of this software and associated documentation files (the "Software"),
    4.12 @@ -46,6 +46,7 @@
    4.13  # Patches to apply to source after unpacking, in order
    4.14  SOURCE_PATCHES  = Makefile.am.0.patch,-p1
    4.15  SOURCE_PATCHES += manpage.patch
    4.16 +SOURCE_PATCHES += 19154747.patch,-p1
    4.17  
    4.18  # Regenerate Makefile.in's from Makefile.am's after patching them
    4.19  AUTORECONF=yes