Debugging printing – CUPS
Some time ago I noticed that printing works somewhat strange on my desktop. It ran smoothly in most of the cases, but rarely it refuse to produce output. The really weird thing is that I didn’t know why it behaved in such a strange manner. As it is stated Murphy’s laws, it seem to fail when I was in a time-pressure situations. “Luckily”, One day, when my printer produced an error instead of doing its job, I had a time to solve the problem.
Analysis – user part
First of all, I needed to work out what is the real problem. I tried printing a few different documents. I selected those problematic and checked whether they are printable with other programs or configuration. The basic rules are:
- Repeatability and reproducibility – in what kind of situation does problem occur? Am I able to reproduce errors within doing the same steps? Does the problem repeat while using certain applications or it is document/configuration specific?
- Isolation – what kind of programs are involved? Pinpoint all of the programs and configuration files that could cause the problem.
My answers to this questions:
- Repeatability and reproducibility – the problem seems to be document specific. I found that it occur only within a small number of PDF and ps files.
- Isolation – printing program related to CUPS such as ghostscript, pnm2ppa, foomatic and CUPS itself.
Analysis – debugging
At first I looked up for logs (“/var/log/cups/error_log”). It wasn’t useful at all, however It suggested turning on the debugging mode. So I look into CUPS config (“/etc/cups/cupsd.conf”) and changed LogLevel to debug.
[code lang="bash"]
#LogLevel info
LogLevel debug
[/code]
I tried printing one of those baffling documents. I looked at errors and saw:
[code lang="bash"]
(...)
D [17/Apr/2007:22:15:56 +0200] [Job 151] GPL Ghostscript 8.54 (2006-05-17)
D [17/Apr/2007:22:15:56 +0200] [Job 151] Copyright (C) 2006 artofcode LLC, Benicia, CA. All rights reserved.
D [17/Apr/2007:22:15:56 +0200] [Job 151] This software comes with NO WARRANTY: see the file PUBLIC for details.
D [17/Apr/2007:22:15:56 +0200] [Job 151]
D [17/Apr/2007:22:15:56 +0200] [Job 151] Closing renderer
D [17/Apr/2007:22:15:56 +0200] [Job 151] Error: /VMerror in --stringwidth--
(...)
[/code]
So it is definitely a ghostscript error. I googled VMerror and found that it is a postscript error which means that my RIP (ghostscript in this case) doesn’t have enough memory. Because I have a lot of free RAM, it is probably a bug of ghostcript.
Solution
I simple searched for ghostscript alternatives in the portrage(“eix ghostscript”). I decided to switch from “ghostscript-GPL” to “ghostscript-esp” so I entered:
[code lang="bash"]
emerge --unmerge app-text/ghostscript-GPL
emerge app-text/ghostscript-esp
/etc/init.d/cups restart # restarting cups service
[/code]
After these steps printing services work properly.