Here is more information. This is the basic test code:
#include <X11/Xlib.h>
#include <X11/Shell.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <time.h>
struct timespec ts;
void timeout(XtPointer p, XtIntervalId* i)
{
exit(0);
}
int main(int argc, char* argv[])
{
ts.tv_sec = 2;
ts.tv_nsec = 900 * 1000;
int xtime_out = 300; // in ms
XtAppContext context;
Widget top;
Display* dpy;
top = XtVaAppInitialize(&context, "ClearCutBuffers",
0, 0, &argc, argv, NULL,NULL);
dpy = XtDisplay(top);
XStoreBuffer(dpy, "", 0, 0);
while (nanosleep(&ts, &ts) != 0);
XtAppAddTimeOut(context, xtime_out, timeout, 0);
XtAppMainLoop(context);
return 0;
}
Following are all ten possible orderings
of either two or three of the following lines.
XtAppAddTimeOut(context, xtime_out, timeout, 0);
XStoreBuffer(dpy, "", 0, 0);
while (nanosleep(&ts, &ts) != 0);
NO, means the bug does not occur. YES, means it does occur. The sleep
period must be long enough or the bug always occurs (if XStoreBuffer
is called). Here it is over 1 s. Also the main loop must be entered
for the loop to appear.
--------------------------------------------------
NO:
XtAppAddTimeOut(context, xtime_out, timeout, 0);
XStoreBuffer(dpy, "", 0, 0);
while (nanosleep(&ts, &ts) != 0);
NO:
XtAppAddTimeOut(context, xtime_out, timeout, 0);
while (nanosleep(&ts, &ts) != 0);
XStoreBuffer(dpy, "", 0, 0);
NO
XStoreBuffer(dpy, "", 0, 0);
XtAppAddTimeOut(context, xtime_out, timeout, 0);
while (nanosleep(&ts, &ts) != 0);
NO
while (nanosleep(&ts, &ts) != 0);
XtAppAddTimeOut(context, xtime_out, timeout, 0);
NO
XtAppAddTimeOut(context, xtime_out, timeout, 0);
while (nanosleep(&ts, &ts) != 0);
YES
while (nanosleep(&ts, &ts) != 0);
XtAppAddTimeOut(context, xtime_out, timeout, 0);
XStoreBuffer(dpy, "", 0, 0);
YES
while (nanosleep(&ts, &ts) != 0);
XStoreBuffer(dpy, "", 0, 0);
XtAppAddTimeOut(context, xtime_out, timeout, 0);
YES
XStoreBuffer(dpy, "", 0, 0);
while (nanosleep(&ts, &ts) != 0);
XtAppAddTimeOut(context, xtime_out, timeout, 0);
YES (after sleep)
XStoreBuffer(dpy, "", 0, 0);
while (nanosleep(&ts, &ts) != 0);
YES
while (nanosleep(&ts, &ts) != 0);
XStoreBuffer(dpy, "", 0, 0);
-- John Lapeyre
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]