Bug 52505 - Ghostscript with omni patch rereading old data from stdin
Ghostscript with omni patch rereading old data from stdin
Product: Red Hat Raw Hide
Classification: Retired
Component: libstdc++ (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
Aaron Brown
Depends On:
  Show dependency treegraph
Reported: 2001-08-24 10:33 EDT by Jonathan Kamens
Modified: 2007-04-18 12:36 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-01-10 04:49:32 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jonathan Kamens 2001-08-24 10:33:44 EDT
The best way to explain this bug is by describing how to reproduce it.

Put this in a file called "foo.ps":

---cut here---
0 0 moveto
72 72 lineto
---cut here---

It actually doesn't really matter what you put in this file, as long as
it's a short, valid PostScript program.

Now, run this command:

(cat > /dev/null ; gs -dSAFER -dNOPAUSE -q -sDEVICE=ljet4
-sOutputFile=/dev/null foo.ps; echo '') < foo.ps

With ghostscript-6.51-10, you will see this:


With ghostscript-6.51-6, you will see this:


That is, it will only print one prompt instead of six.  Why the
difference?  Because for some reason, ghostscript-6.51-10 is rewinding
stdin and reading the data in foo.ps, even though the "cat > /dev/null"
command has already read it.  I narrowed this down to sread_file in
sfxstdio.c.  It appears that ftell(file) is returning 0 on stdin even
though stdin's real position is not 0.

You can duplicate this problem outside of ghostscript by compiling this
simple test program with c++ instead of cc (i.e., "c++ test.c"):

---cut here---
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>

  int real_position = lseek(fileno(stdin), 0, SEEK_CUR);
  int stdio_position = ftell(stdin);

  printf("really = %d, stdio = %d\n", real_position, stdio_position);
---cut here---

Then run "(cat; ./a.out) < foo.ps" (where "foo.ps" is as shown above, or
heck, you can use any file you want), and you'll see that the "really" and
"stdio" numbers are different.  If you compile the same program with cc,
the numbers are the same.

This suggests that there is a bug in the C++ libraries, and I will file a
separate bug report about that, but until it's fixed, the omni patch should
probably be removed from ghostscript unless it can be made to link without
using c++.
Comment 1 Jakub Jelinek 2001-09-18 04:18:34 EDT
As gs is dynamically linked against libstdc++, this should work with
libstdc++-2.96-98 and above (I've even tried it).

Note You need to log in before you can comment on or make changes to this bug.