Community
Participate
Working Groups
On Linux RedHat 7.0 , if you call XInitThreads and link with pthread, the first Xp call will hang. Here are the steps to reproduce it: 1) Compile the attached C code in a machine with XPrinting installed. 2) Setup a X printing server by running the following as root: Xprt :1 & 3) Run the executable "test". It should print out "start" and then hang. 4) Comment the following line in the makefile LIB_FLAGS += -lpthread 5) Recompile the tescase. 6) Run it again. It should not hang this time. ++++++++++++++++++++++++ makefile ++++++++++++++++++++++++++++++++ LIB_FLAGS = -L/usr/X11R6/lib -lXt -lX11 -lXp -lXext OBJS = print_hang.o # Comment this line and the test will not hang LIB_FLAGS += -lpthread all: $(OBJS) cc -o test $(OBJS) $(LIB_FLAGS) +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++ print_hang.c +++++++++++++++++++++++++++++ #include <X11/Intrinsic.h> #define PRINTER_NAME ":1" int main(int argc, char **argv) { XtAppContext xPrinterContext; Display *xPrinter; short major, minor; printf("start\n"); XInitThreads(); XtToolkitThreadInitialize(); XtToolkitInitialize(); xPrinterContext = XtCreateApplicationContext(); xPrinter = XtOpenDisplay(xPrinterContext, PRINTER_NAME, NULL, NULL, NULL, 0, &argc, argv); if (xPrinter != NULL) { XpQueryVersion(xPrinter, &major, &minor); printf("XpExtension %d.%d\n", major, minor); } else { printf("Failed to open printer\n"); } XtDestroyApplicationContext(xPrinterContext); printf("end\n"); } ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ NOTES:
PRODUCT VERSION: Red Hat 7.0
This is a third part problem. The problem has been worked around in SWT by avoiding the call to XInitThreads().
There is a patch for the bug available in http://xprint.mozdev.org/bugs/show_bug.cgi?id=4055
Hi David, Thanks for the info. It is good to know that there are more people hitting this problem. I believe the patch only fix one instance of the problem, since the problem is really in XFree86 threading support. It happens with Xinput method also. Silenio