Bug 4775 - XInitThreads causes X printing to hang (1GITBQL)
Summary: XInitThreads causes X printing to hang (1GITBQL)
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.0   Edit
Hardware: All Linux
: P3 normal (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 4411
  Show dependency tree
 
Reported: 2001-10-11 14:22 EDT by Silenio Quarti CLA
Modified: 2003-10-29 11:44 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Silenio Quarti CLA 2001-10-11 14:22:48 EDT
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:
Comment 1 DJ Houghton CLA 2001-10-29 16:37:38 EST
PRODUCT VERSION:

Red Hat 7.0

Comment 2 Silenio Quarti CLA 2002-03-05 19:18:58 EST
This is a third part problem. The problem has been worked around
in SWT by avoiding the call to XInitThreads().
Comment 3 David Schweiger CLA 2003-10-28 20:35:58 EST
There is a patch for the bug available in
http://xprint.mozdev.org/bugs/show_bug.cgi?id=4055
Comment 4 Silenio Quarti CLA 2003-10-29 11:44:03 EST
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