[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1118061: cups: No space left on /tmp causes "Unable to get scanline 0!" error



Package: cups
Version: 2.4.2-3+deb12u9
Severity: normal
X-Debbugs-Cc: cjp@ultimatestunts.nl

Dear Maintainer,

I have a Raspberry Pi 4 running Debian Bookworm (aarch64), and I have CUPS
installed to serve an Epson L1250 printer (USB connection, using the L3250
driver). I've successfully printed several documents, but one single-page PDF
file failed to print (it caused the printer to move one page without printing
anything on it). On the web interface, the print job of this file shows the
error message "Unable to get scanline 0!". Unfortunately, I cannot share this
particular PDF file for privacy reasons, but I've investigated this bug myself,
and I can share my conclusions on what should be fixed.

With debug logging enabled in CUPS, I found out in /var/log/cups/error_log that
gstoraster is one of the filters used, which calls ghostscript ("gs") for
converting PDF to raster data. I found on the internet that this particular
error message is generated by ghostscript, and I could reproduce the error
message by manually calling gs on my PDF file with similar arguments as done by
CUPS. Interestingly, it failed on my Raspberry Pi, but succeeded on my amd64
laptop. I tried to use gdb to figure out the difference, but that was too much
work.

Then I decided to run ghostscript in strace, and check for differences between
the Raspberry Pi and the laptop. On the Pi, I found that several write commands
returned -1 ENOSPC, and the file descriptor corresponded to a file in /tmp.
Apparently, ghostscript was writing files in /tmp, which was too small on the
Pi. Increasing the size of /tmp on the Raspberry Pi (from 20MB to 256MB)
resolved the issue for me, at least for this particular PDF file. This proves
that lack of space on /tmp was the cause of the issue.

So, right now "it works for me". However, there are some loose ends that should
be fixed. What should be fixed in ghostscript, is that "Unable to get scanline
0!" is not a clear error message when the cause is a full /tmp. "Could not
write to <filename>: no space left on device" would have been much better. And
there's something that should be fixed in CUPS too:

Ghostscript supports setting the temporary directory to whatever is given to it
in the TMPDIR environment variable[1]. gstoraster just forwards all its
environment variables to ghostscript. But somehow CUPS doesn't pass TMPDIR to
gstoraster (confirmed by gstoraster's logging in /var/log/cups/error_log). This
is regardless of what I write in /etc/cups/cups-files.conf (I tried both
TempDir /var/spool/cups/tmp and PassEnv TMPDIR=/var/spool/cups/tmp).

I believe this is because "scheduler/cupsfilter.c" writes an entirely new
environment for filter child processes (line 1120 and following in version
2.4.14-1), which doesn't contain TMPDIR. As a result, ghostscript doesn't know
it should use /var/spool/cups/tmp, so it defaults to /tmp.

I believe it would be better to modify "scheduler/cupsfilter.c", so that it
forwards the TMPDIR environment variable to child processes.

kind regards,
CJP

PS. the system information attached is for my laptop, while the bug occurred on
the Raspberry Pi. Please ignore the system information. There's no much need
for it anyway, since the cause of the bug is already clear.

[1] https://web.mit.edu/ghostscript/src/ghostscript-8.14/doc/Use.htm


-- System Information:
Debian Release: 12.12
  APT prefers oldstable-updates
  APT policy: (500, 'oldstable-updates'), (500, 'oldstable-security'), (500, 'oldstable-proposed-updates-debug'), (500, 'oldstable-debug'), (500, 'oldstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.1.0-40-amd64 (SMP w/4 CPU threads; PREEMPT)
Locale: LANG=nl_NL.UTF-8, LC_CTYPE=nl_NL.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages cups depends on:
ii  cups-client            2.4.2-3+deb12u9
ii  cups-common            2.4.2-3+deb12u9
ii  cups-core-drivers      2.4.2-3+deb12u9
ii  cups-daemon            2.4.2-3+deb12u9
ii  cups-filters           1.28.17-3+deb12u1
ii  cups-ppdc              2.4.2-3+deb12u9
ii  cups-server-common     2.4.2-3+deb12u9
ii  debconf [debconf-2.0]  1.5.82
ii  ghostscript            10.0.0~dfsg-11+deb12u8
ii  libavahi-client3       0.8-10+deb12u1
ii  libavahi-common3       0.8-10+deb12u1
ii  libc6                  2.36-9+deb12u13
ii  libcups2               2.4.2-3+deb12u9
ii  libgcc-s1              12.2.0-14+deb12u1
ii  libstdc++6             12.2.0-14+deb12u1
ii  libusb-1.0-0           2:1.0.26-1
ii  poppler-utils          22.12.0-2+deb12u1
ii  procps                 2:4.0.2-3

Versions of packages cups recommends:
ii  avahi-daemon  0.8-10+deb12u1
ii  colord        1.4.6-2.2

Versions of packages cups suggests:
pn  cups-bsd                                   <none>
pn  cups-pdf                                   <none>
pn  foomatic-db-compressed-ppds | foomatic-db  <none>
pn  smbclient                                  <none>
ii  udev                                       252.39-1~deb12u1

-- debconf information excluded


Reply to: