An actual fix for the printing frustrations

I tried again to print some documents, following what I thought was The Fix(tm), as mentioned in the previous post. However … blam! cupsd fell over again and the service was placed into maintenance, with the same signature as before: a core from /usr/bin/gs with that same stack.

Frustration. Level. Rising ……. AAARRRGGGGHHHHH

So I found our copy of the sources for Gutenprint, ghostscript and Cups, built up cscope database and started searching for the cmd_put_list_op function and what might affect it. I also turned on debug logging in /etc/cups/cupsd.conf and scanned megabytes of output for several hours this evening. After a while, something twigged – perhaps cups’ RIP_MAX_CACHE might have something to do with the problem – after all, each reported crash was due to SIGSEGV (11), which is almost always a memory allocation or memory stomping problem.

This setting is for the Raster Image Processor (RIP) and limits the amount of memory which it is allowed to allocate. Since I knew already that printing plain text files (/etc/passwd is a great testbed for this) was fine, and that complex PDF or PostScript docs weren’t, I thought I might be on to something. Cups uses getenv() to check the value of the variable, so I first tried

$ RIP_MAX_CACHE=16m lp -d lp1onfire

but that value wasn’t passed through to the RIP (/usr/bin/gs).

Next, I tried editing /usr/lib/cups/filter/pstoraster, a mere shell-script, adding


just before the invocation of ghostscript.

Again, no joy. Then I googled for ways to change the setting with cups, and quickly came across the cups parameter RIPcache. It’s easy to set – just add a line to your /etc/cups/cupsd.conf with the desired value, and restart. I chose 16m to start with, and finally saw the value being passed through:

D [04/Oct/2012:00:00:27 -1000] [Job 25] envp[21]="RIP_MAX_CACHE=16m"

It was not, however, sufficient for my test document. A quick change to 128m and a restart … et voila! printing!

My stress level dropped immediately


I’ve updated my cupsd.conf to now have a RIPcache value of 512m, and (finally) turned off debug logging.