Bug 690124

Summary: ps2ascii crashes immediately, independent of the input
Product: Ghostscript Reporter: Till Kamppeter <till.kamppeter>
Component: TextAssignee: Alex Cherepanov <alex>
Status: NOTIFIED FIXED QA Contact: Bug traffic <tech>
Severity: critical    
Priority: P4    
Version: 8.63   
Hardware: PC   
OS: Linux   
Customer: Word Size: ---
Attachments: 11_gs-cjk_font_glyph_handling_fix.dpatch

Description Till Kamppeter 2008-10-15 13:08:50 UTC
See Ubuntu bug report


The reporter complains that ps2ascii (Ghostscript wrapper script to extract the
text out of a PostScript file) doe not work any more in Ghostscript 8.63. The
script crashes with the following error, independent of the input file:

Username@Kubuntu:~$ ps2ascii
Error: /rangecheck in --put--
Operand stack:
   --nostringval-- false setshared .inew --nostringval-- --nostringval-- 1500
Execution stack:
   %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2
%stopped_push --nostringval-- --nostringval-- --nostringval-- false 1
%stopped_push 1904 2 3 %oparray_pop 1903 2 3 %oparray_pop 1887 2 3 %oparray_pop
1771 2 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval--
--nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval--
Dictionary stack:
   --dict:1163/1684(G)-- --dict:0/20(G)-- --dict:94/200(L)-- --dict:1163/1684(G)--
Current allocation mode is global
Current file position is 8319
GPL Ghostscript 8.63: Unrecoverable error, exit code 1

I have tried to fix/work around it by removing the "-dDELAYBIND" command line
option from the Ghostscript command line by editing the /usr/bin/ps2ascii script
appropriately. It worked for me (I tried only 2 files), but the reporter tells
that Ghostscript segfaults then. The reporter then replaced "-dDELAYBIND" by
"-dNOBIND" then and was successful with all his files then.

WDYT? Is this a viable fix?

I am very grateful for a quick answer, as tomorrow, Thursday, October 16, Ubuntu
Intrepid has release freeze.
Comment 1 Alex Cherepanov 2008-10-15 20:44:13 UTC
I cannot reproduce this problem in the current revision on Win32 or
x86 Linux.
Comment 2 Marcos H. Woehrmann 2008-10-16 08:29:11 UTC
I can't duplicate this either.  I'm using Ubuntu 8.04 on an amd64 system with Ghostscript 8.63.

Comment 3 Ralph Giles 2008-10-16 10:51:05 UTC
I cannot reproduce with 8.63 or HEAD on x86_64 Ubuntu 8.04, nor with HEAD on
Ubuntu 8.10.

I can reproduce with the gs executable shipping with Ubuntu 8.10. So the culprit
is likely one of the patches the Ubuntu applies in their package.
Comment 4 Ralph Giles 2008-10-16 13:42:05 UTC
Ok, I've confirmed using the ubuntu intrepid source package

./configure && make
stop -f lib/ps2ascii.ps examples/alphabet.ps -c quit

rm -rf bin obj
debian/rules patch
[add -lpaper to EXTRALIBS in the makefile]
./configure && make
stop -f lib/ps2ascii.ps examples/alphabet.ps -c quit
Error: /rangecheck in --put--

So the culprit is indeed one of the patches, and it's not our bug. If you want
help sorting this problem, it would help to at least track down which patch is
Comment 5 Till Kamppeter 2008-10-17 00:48:55 UTC
I have found the patch which is the culprit: It is the patch
debian/patches/11_gs-cjk_font_glyph_handling_fix, which seems to add a complete
CJK handling subsystem.

Can you check this patch and perhaps find out if it is still needed and if so,
if you could fix it.

Can you also check the need of
Comment 6 Alex Cherepanov 2008-10-17 08:23:29 UTC
Please provide URLs to the patches or attach them to the bug report.
Comment 7 Till Kamppeter 2008-10-17 10:02:04 UTC
Created attachment 4514 [details]

Patch to add advanced CJK support. This patch causes this bug.
Comment 8 Till Kamppeter 2008-10-17 10:02:55 UTC
Created attachment 4515 [details]

Additional patch for vertical CJK printing
Comment 9 Till Kamppeter 2008-10-17 10:03:47 UTC
Created attachment 4516 [details]

Patch which adds test files for the above two patches
Comment 10 Alex Cherepanov 2008-10-18 18:18:43 UTC
Created attachment 4519 [details]

Extend the size of the array for procedures scheduled for binding
in the DELAYBIND mode to 2000. Prevent an overflow when 3rd party code
(such as Ubuntu CJKV patch) defines and binds many procedures.
Comment 11 Alex Cherepanov 2008-10-18 18:25:53 UTC
The patch is committed as a rev. 9174.

DELAYBIND mode is not covered by regression testing.
Regressions cannot happen.
Comment 12 Till Kamppeter 2008-10-19 02:45:23 UTC
I have checked and it works. Text extraction works perfectly now for me with
both PostScript and PDF input file.