XAllocID usage in libxview requires a new solution / problem in xcb_io.c
I am currently trying to compile SunOS libxview for MacOS x86_64/arm64. My repository is
https://github.com/21tesla/libxview-macos
From what I have read, there is a problem with the way XAllocID is called thereby producing the following error:
Assertion failed: (ret != inval_id), function _XAllocID, file xcb_io.c, line 520.
There was a solution suggested; however, it does not appear to work anymore. I believe the problem is tied a bad implementation of XAlloc in server.c where XAlloc is called too many times. The best comment on it I could find was from 11 years ago!
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 https://bugs.freedesktop.org/show_bug.cgi?id=27552 and https://xcb.pdx.freedesktop.narkive.com/vsAJcfE3/calling-xallocid-twice-causes-assertion-ret-inval-id-failed >
Here is the chunk of problematic code and the two options to call XAllocID that I have tested.
#ifndef __APPLE__
(void) fprintf( stderr, "using xidLIst \n" );
XAllocIDs((Display *)server->xdisplay, xidList, 4 );
/* XAllocIDs ((Display *)server->xdisplay, server->atom_mgr, 4); */
server->atom_mgr[ATOM] = xidList[0];
server->atom_mgr[NAME] = xidList[1];
server->atom_mgr[TYPE] = xidList[2];
server->atom_mgr[DATA] = xidList[3];
#else
(void) fprintf( stderr, "using XAllocID \n" );
server->atom_mgr[ATOM] = (XID) XAllocID((Display *)server->xdisplay);
server->atom_mgr[NAME] = (XID) XAllocID((Display *)server->xdisplay);
server->atom_mgr[TYPE] = (XID) XAllocID((Display *)server->xdisplay);
server->atom_mgr[DATA] = (XID) XAllocID((Display *)server->xdisplay);
#endif
thank you for any insight
logan donaldson