Bug 789 - Xprt may hang when CUPS spooler sends messages to stdout
Summary: Xprt may hang when CUPS spooler sends messages to stdout
Status: RESOLVED FIXED
Alias: None
Product: xprint
Classification: Unclassified
Component: Server: Spooler support: CUPS (show other bugs)
Version: unspecified
Hardware: All Linux (All)
: high critical
Assignee: Roland Mainz
QA Contact:
URL: http://xprint.mozdev.org/pipermail/xp...
Whiteboard:
Keywords:
Depends on:
Blocks: 790
  Show dependency treegraph
 
Reported: 2004-06-22 03:02 UTC by Roland Mainz
Modified: 2004-06-21 10:20 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Patch for 2004-06-21-oldcvs_trunk (1.67 KB, patch)
2004-06-22 03:11 UTC, Roland Mainz
no flags Details | Splinter Review
Patch for 2004-06-21-trunk (3.09 KB, patch)
2004-06-22 03:18 UTC, Roland Mainz
no flags Details | Splinter Review

Description Roland Mainz 2004-06-22 03:02:35 UTC
[Originally reported at
http://xprint.mozdev.org/pipermail/xprint/2004-June/000227.html by
philip.webley@gmx.at ]
---- snip ----
Hi

xprint-request at mozdev.org wrote:

>> > Another question is definetely about xprint. When experimenting, I
>> > decided to try option -XpSpoolerType cups. This resulted in deadlocking
>> > of the clients. Even xphelloworld was deadlocked. The printing was done,
>> > but I guess the socket was not closed after it, so the client was
>> > sitting there till the server was terminated. I do have CUPS running so
>> > I find this behaviour kind of strange. As far as I understand the
>> > default value for this option is 'bsd:cups'
>>[snip]
>>
>>I had the same sort of trouble but was able to fix it by specifying
>>
>>*xp-spooler-command: /usr/bin/lp -s
>>
>>in /etc/Xprint/C/print/attributes/printer
>>
>>This suppresses console output from lp, so it looks like the output
>>(printjob ID) from lp is confusing Xprt somehow.
> 
> 
> Weired, very weired.
> 
> David Schweiger had a good idea - can you try to attach gdb to the Xprt
> process and provide a stack trace of the hung Xprt, please ?
> 
OK, I compiled xprint with -g and got these gdb traces for Xprt and 
xphelloworld (taken with the system hung). I'm not skilled with gdb but 
maybe you can make something out of them:

--snip--
This GDB was configured as "i386-linux"...Using host libthread_db 
library "/lib/libthread_db.so.1".

Attaching to program: /usr/local/bin/Xprt, process 9243
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
0x40117dd2 in select () from /lib/libc.so.6
(gdb) bt
#0  0x40117dd2 in select () from /lib/libc.so.6
#1  0x40176510 in ?? () from /lib/libc.so.6
#2  0x400164a0 in ?? () from /lib/ld-linux.so.2
#3  0xbffff360 in ?? ()
#4  0x08083587 in WaitForSomething (pClientsReady=0xbffff3a4) at 
WaitFor.c:323
#5  0x08071a6a in Dispatch () at dispatch.c:253
#6  0x0805889f in main (argc=12, argv=0xbffff854) at main.c:364
(gdb)
--snip--

--snip--
This GDB was configured as "i386-linux"...Using host libthread_db 
library "/lib/libthread_db.so.1".

Attaching to program: /usr/bin/xphelloworld, process 9278
Reading symbols from /usr/X11R6/lib/libXext.so.6...done.
Loaded symbols for /usr/X11R6/lib/libXext.so.6
Reading symbols from /usr/X11R6/lib/libX11.so.6...done.
Loaded symbols for /usr/X11R6/lib/libX11.so.6
Reading symbols from /usr/X11R6/lib/libXp.so.6...done.
Loaded symbols for /usr/X11R6/lib/libXp.so.6
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/libnss_compat.so.2...done.
Loaded symbols for /lib/libnss_compat.so.2
Reading symbols from /lib/libnsl.so.1...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libnss_nis.so.2...done.
Loaded symbols for /lib/libnss_nis.so.2
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
0x401f5dd2 in select () from /lib/libc.so.6
(gdb) bt
#0  0x401f5dd2 in select () from /lib/libc.so.6
#1  0x400f8d28 in ?? () from /usr/X11R6/lib/libX11.so.6
#2  0x0804f988 in ?? ()
#3  0x00000000 in ?? ()
#4  0x40065e92 in _XPollfdCacheDel () from /usr/X11R6/lib/libX11.so.6
#5  0x40066e01 in _XRead () from /usr/X11R6/lib/libX11.so.6
#6  0x40066a54 in _XReadEvents () from /usr/X11R6/lib/libX11.so.6
#7  0x40051e32 in XIfEvent () from /usr/X11R6/lib/libX11.so.6
#8  0x0804b457 in XpuWaitForPrintNotify ()
#9  0xbffff6a0 in ?? ()
#10 0x0804b3f0 in XpuGetOneLongAttribute ()
Previous frame inner to this frame (corrupt stack?)
(gdb)
--snip--

BTW, Where is stdout from lp *supposed* to go? Is it used for anything?
I tried redirecting stdout to /dev/null in SendFileToCommand() in 
xprint/src/xprint_main/xc/programs/Xserver/Xprint/attributes.c
using the following patch - this also fixes the problem:

--snip--
*** 
/usr/local/src/xprint-xprintorg-0.0.9.final/xprint/src/xprint_main/xc/programs/Xserver/Xprint/attributes.c 
  Sat Jun 19 23:48:13 2004
--- 
/usr/local/src/xprint-xprintorg-0.0.9.final/local-patches/attributes.c 
    Sun Jun 20 12:46:19 2004
***************
*** 1127,1132 ****
--- 1127,1133 ----
   {
       pid_t childPid;
       int pipefd[2];
+     int fd;
       int status;
       struct stat statBuf;
       FILE *fp, *outPipe;
***************
*** 1155,1161 ****
         close(0);
         dup(pipefd[0]);
         close(pipefd[0]);
!
         /*
          * If a user name is specified, try to set our uid to match that
          * user name.  This is to allow e.g. a banner page to show the
--- 1156,1166 ----
         close(0);
         dup(pipefd[0]);
         close(pipefd[0]);
!
!       /* redirect stdout to /dev/null */
!       close(1);
!       fd = open("/dev/null", O_RDWR);
!
         /*
          * If a user name is specified, try to set our uid to match that
          * user name.  This is to allow e.g. a banner page to show the
--snip--

The problem is only with stdout - output to stderr goes to a logfile 
quite normally and doesn't cause the system to hang.
---- snip ----
Comment 1 Roland Mainz 2004-06-22 03:09:56 UTC
The correct solution for this would be to store the spooler command output in
the "xp-spooler-command-results" resource, however this needs little bit testing
so I am going to implement a workaround based on your patch and move the
implementation of a real solution to bug 790 ("RFE: Xprt should store the output
of the spooler command in the "xp-spooler-command-results" resource").
Comment 2 Roland Mainz 2004-06-22 03:11:11 UTC
Created attachment 404 [details] [review]
Patch for 2004-06-21-oldcvs_trunk
Comment 3 Roland Mainz 2004-06-22 03:13:03 UTC
attachment 404 [details] [review] checked-in...

/cvs/xprint/xprint/src/xprint_main/xc/programs/Xserver/Xprint/attributes.c,v 
<--  attributes.c
new revision: 1.7; previous revision: 1.6
Comment 4 Roland Mainz 2004-06-22 03:18:46 UTC
Created attachment 405 [details] [review]
Patch for 2004-06-21-trunk
Comment 5 Roland Mainz 2004-06-22 03:20:46 UTC
attachment 405 [details] [review] checked-in...

/cvs/xorg/xc/ChangeLog,v  <--  ChangeLog
new revision: 1.70; previous revision: 1.69
/cvs/xorg/xc/programs/Xserver/Xprint/attributes.c,v  <--  attributes.c
new revision: 1.4; previous revision: 1.3
Mailing the commit message to xorg-commit@pdx.freedesktop.org...

... marking bug as FIXED.

Followup is bug 790 to get the "xp-spooler-command-results" functionality
implemented.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.