[Xcb] Calling XAllocID() twice causes assertion `ret != inval_id' failed

Matthieu Herrb matthieu.herrb at laas.fr
Sun Jul 11 02:17:37 PDT 2010


I'm trying to help someone understanding why an application using
the old XView (from OpenWindows) toolkit is crashing with the infamous)

xcb_io.c:378: _XAllocID: Assertion `ret != inval_id' failed.

He figured out that this happens because xview sometimes calls XAllocID() 
twice in a row.

Indeed the program below reproduces the problem. Looking at libX11
source code, it's obvious why this happens. Since XView is inherently
not thread-safe, there is no multi-threading involved and
XInitThreads() is never called, so dpy->lock is NULL and so _XIDHandler() 
is never called by XLockDisplay(), thus the xcb->next_xid field 
stays 'invalid_id'. 

I think this is a bug, and could be also one cause of 


#include <stdio.h>
#include <X11/Xlib.h>

int main(int argc, char** args) {

	Display * dpy;

	dpy = XOpenDisplay(NULL);
	printf("Display = %08x\n", dpy);
	int i;
	for (i = 0; i < 100; i++) {
		int xid = XAllocID(dpy);
		printf("xid = %08x\n", xid);

Matthieu Herrb

More information about the Xcb mailing list