OpenPrinting / OpenPrinting/libcupsfilters
Ghostcript used to find the number of pages on output could fail
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 17
- Forks
- 71
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 13
Description
Hello,
I have experienced ghostscript failure to produce expected output for my specific input document.
Error: /rangecheck in --getinterval--
Operand stack:
ClippedLabel () 0 -1
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nost
ringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1933 1 3 %oparray_pop 1932
1 3 %oparray_pop 1917 1 3 %oparray_pop 1787 1 3 %oparray_pop --nostringval-- %error
exec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval
-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval--
%loop_continue
Dictionary stack:
--dict:745/1123(ro)(G)-- --dict:0/20(G)-- --dict:88/200(L)-- --dict:34/100(L)-- --dict:31/100(L)--
Current allocation mode is local
Current file position is 15757 GPL Ghostscript 10.05.1: Unrecoverable error, exit code 1
It seems it is unable to generate output which cfFilterGhostscript() uses to cound the number of pages in the input document.
cupsfilters/ghostscript.c:
...
1032 // Ghostscript runs too long on files converted from djvu files
1033 // Using -dDEVICEWIDTHPOINTS -dDEVICEHEIGHTPOINTS params solves the
1034 // problem
1035 snprintf(gscommand, 65536, "%s -q -dNOPAUSE -dBATCH -sDEVICE=bbox -dDEVICEWIDTHPOINTS=1 -dDEVICEHEI GHTPOINTS=1 %s 2>&1 | grep -c HiResBoundingBox",
1036 CUPS_GHOSTSCRIPT, filename);
...
I have found well working alternative to this potentially problematic approach. It uses inkcov gs device. See the attached patch and consider merging it.
Thank you,
m.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in cupsfilters/ghostscript.c around lines 1032-1036 and review how the Ghostscript bbox command is used to count pages. Compare the attached inkcov-based patch with the current approach, then verify that the failing input no longer triggers the rangecheck error and produces the expected page count.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100