Bug 691137

Summary: "Can't refill scanner input buffer" error when Ubuntu test page (PostScript) fed into GS via stdin
Product: Ghostscript Reporter: Till Kamppeter <till.kamppeter>
Component: PS InterpreterAssignee: Alex Cherepanov <alex>
Status: RESOLVED DUPLICATE    
Severity: major    
Priority: P4    
Version: 8.71   
Hardware: PC   
OS: Linux   
Customer: Word Size: ---
Attachments: testpage-a4.ps
ps2pdfwr

Description Till Kamppeter 2010-02-23 13:47:23 UTC
If I run these command lines:

1. cat /usr/share/system-config-printer/testpage-a4.ps | gs -

2. cat /usr/share/system-config-printer/testpage-a4.ps | /usr/bin/ps2pdf13
-dAutoRotatePages=/None -dAutoFilterColorImages=false -dNOPLATFONTS
-dPARANOIDSAFER -sstdout=%stderr -dColorImageFilter=/FlateEncode
-dPDFSETTINGS=/printer -dDoNumCopies - out.pdf

I get the following error:

GPL Ghostscript 8.71: ./psi/iscan.c(333): Can't refill scanner input buffer!GPL
Ghostscript 8.71: Unrecoverable error, exit code 255

This happens after the frames are rendered (out.pdf contains only the frames).

Supplying the input file directly on the command line (at the places where the
single "-" are) they get correctly rendered.

Ghostscript is version 8.71 on Ubuntu Lucid, 64-bit.
Comment 1 Till Kamppeter 2010-02-23 13:49:07 UTC
Created attachment 5982 [details]
testpage-a4.ps

Offending file: Ubuntu test page.
Comment 2 Till Kamppeter 2010-02-23 14:48:22 UTC
Problem is that the PS Interpreter tries to seek on the input file for certain
files. A fix would be to avoid seeking under all circumstances, for example by
reading bigger pieces into a buffer.

A workaround is to never call Ghostscript with "-" as input file but always use
"-_" instead. For this especially also all scripts which come with Ghostscript
need to be fixed. See the attached ps2pdfwr as an example. The additional

if [ "${infile}" = "-" ]; then
    infile="-_"
fi

solves the problem when any ps2pdf* script is used.
Comment 3 Till Kamppeter 2010-02-23 14:49:59 UTC
Created attachment 5983 [details]
ps2pdfwr

ps2pdfwr which uses "-_" instead of "-" in its Ghostscript call when input
comes from stdin.
Comment 4 Alex Cherepanov 2010-02-23 15:06:59 UTC

*** This bug has been marked as a duplicate of 690909 ***