Bug 516507

Summary: document-format '' advertised when filter not present
Product: [Fedora] Fedora Reporter: Jiri Popelka <jpopelka>
Component: cupsAssignee: Tim Waugh <twaugh>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 11CC: jpopelka, twaugh
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 1.4.1-4.fc11 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-10-14 02:01:04 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 516998    
Attachments:
Description Flags
test.txt as application/octet-stream
none
troubleshoot_lpr.txt
none
Canon-iR-3170C-EUR.ipp
none
gdb output
none
ddd output
none
Proposed patch none

Description Jiri Popelka 2009-08-10 10:23:33 UTC
Created attachment 356870 [details]
test.txt as application/octet-stream

Description of problem:

I created in vi editor test.txt file and
try to print it with lpr
>>>lpr test.txt 
lpr: successful-ok
but nothing is printed.

error_log contains:
D [10/Aug/2009:11:12:11 +0200] [Job 35] Auto-typing file...
D [10/Aug/2009:11:12:11 +0200] [Job 35] Request file type is text/plain.
D [10/Aug/2009:11:12:11 +0200] Send-Document
client-error-document-format-not-supported: Unsupported format 'text/plain'!
E [10/Aug/2009:11:12:11 +0200] Returning IPP
client-error-document-format-not-supported for Send-Document
(ipp://localhost:631/printers/Canon-iR-3170C-EUR) from localhost

And the job status says it was canceled by user.

Version-Release number of selected component (if applicable):

cups-1.4-0.rc1.14.fc11.x86_64

How reproducible:

Always

Steps to Reproduce:

1. create text file in vi
2. lpr test.txt
  
Actual results:

Nothing is printed

Expected results:

Printing

Additional info:

Comment 1 Jiri Popelka 2009-08-10 10:26:19 UTC
Created attachment 356871 [details]
troubleshoot_lpr.txt

Comment 2 Tim Waugh 2009-08-10 10:51:30 UTC
Weirdly, instead of 'text/plain' in document-format-supported there is an empty string.

What does 'rpm -V cups' say?

Comment 3 Jiri Popelka 2009-08-10 11:30:37 UTC
# rpm -V cups
.M.......  c /etc/cups/subscriptions.conf

Comment 4 Tim Waugh 2009-08-10 11:58:52 UTC
Please attach this file:

/var/cache/cups/Canon-iR-3170C-EUR.ipp

Comment 5 Jiri Popelka 2009-08-10 12:55:19 UTC
Created attachment 356885 [details]
Canon-iR-3170C-EUR.ipp

Comment 6 Tim Waugh 2009-08-10 14:29:50 UTC
Please don't restart cups unless absolutely necessary, because the bug might disappear...

Install the cups-debuginfo package:

yum --enablerepo=updates-testing-debuginfo install cups-debuginfo

Check it's the matching version: cups-debuginfo-1.4-0.rc1.14.fc11

Now run 'ps axf | grep [c]upsd' to find out the PID of cupsd.  Let's say it's 4145.

Attach to it with gdb:

gdb /usr/sbin/cupsd 4145
...
(gdb)

Now print out the MimeTypes array:

(gdb) p NumMimeTypes
37
(gdb) p MimeTypes[0]@37

What output do you get?

Comment 7 Jiri Popelka 2009-08-10 14:44:59 UTC
(gdb) p NumMimeTypes
$1 = 35
Current language:  auto; currently minimal
(gdb) p MimeTypes[0]@35
$3 = {0x7fe25622fc44 "application/octet-stream", 0x7fe25621aed4 "application/pdf", 0x7fe25622e044 "application/postscript", 0x7fe25621aef4 "application/rss+xml", 
  0x7fe25621af24 "application/vnd.cups-banner", 0x7fe25621af54 "application/vnd.cups-command", 0x7fe25621af84 "application/vnd.cups-pdf", 0x7fe25621afb4 "application/vnd.cups-postscript", 
  0x7fe25621afe4 "application/vnd.cups-ppd", 0x7fe25621b014 "application/vnd.cups-raster", 0x7fe25621b044 "application/vnd.cups-raw", 0x7fe25621b074 "application/vnd.hp-hpgl", 
  0x7fe25621b0a4 "application/x-cshell", 0x7fe25621b0d4 "application/x-csource", 0x7fe25621b104 "application/x-perl", 0x7fe25621b134 "application/x-shell", 0x7fe25621b164 "image/gif", 
  0x7fe25622e814 "image/jpeg", 0x7fe25622e834 "image/png", 0x7fe25622e324 "image/tiff", 0x7fe25622e344 "image/x-alias", 0x7fe25622e364 "image/x-bitmap", 0x7fe25622e974 "image/x-icon", 
  0x7fe25622e994 "image/x-photocd", 0x7fe25622e9b4 "image/x-portable-anymap", 0x7fe25622e194 "image/x-portable-bitmap", 0x7fe25622e1c4 "image/x-portable-graymap", 0x7fe25622fab4 "image/x-portable-pixmap", 
  0x7fe25622fae4 "image/x-sgi-rgb", 0x7fe25622df74 "image/x-sun-raster", 0x7fe25622fb04 "image/x-xbitmap", 0x7fe25622dfa4 "image/x-xpixmap", 0x7fe25622dfc4 "text/css", 0x7fe25622dfe4 "text/html", 
  0x7fe25622e004 "text/plain"}

Comment 8 Tim Waugh 2009-08-10 14:54:07 UTC
OK, use 'detach' and 'quit' to let it carry on independently of the debugger.

Let's try asking it again which document-formats it supports:

python <<"EOF"
import cups
c=cups.Connection()
print c.getPrinterAttributes('Canon-iR-3170C-EUR')['document-format-supported']
EOF

Comment 9 Jiri Popelka 2009-08-10 15:05:21 UTC
[u'application/octet-stream', u'application/pdf', u'application/postscript', u'application/vnd.cups-banner', u'application/vnd.cups-command', u'application/vnd.cups-postscript', u'application/vnd.cups-raw', u'application/vnd.hp-hpgl', u'application/x-cshell', u'application/x-csource', u'application/x-perl', u'application/x-shell', u'image/gif', u'image/jpeg', u'image/png', u'image/tiff', u'image/x-bitmap', u'image/x-photocd', u'image/x-portable-anymap', u'image/x-portable-bitmap', u'image/x-portable-graymap', u'image/x-portable-pixmap', u'image/x-sgi-rgb', u'image/x-sun-raster', u'image/x-xbitmap', u'image/x-xpixmap', u'text/html', u'']

Comment 10 Jiri Popelka 2009-08-10 15:12:46 UTC
This queue is configured to use AppSocket (as you can see from device URI socket://10.34.255.21:9100). I can also use this printer via another cups server (by using BrowsePoll in cupsd.conf). And in that case everything is OK (the file is correctly printed).
[u'application/octet-stream', u'application/pdf', u'application/postscript', u'application/rss+xml', u'application/vnd.cups-banner', u'application/vnd.cups-command', u'application/vnd.cups-pdf', u'application/vnd.cups-postscript', u'application/vnd.cups-ppd', u'application/vnd.cups-raster', u'application/vnd.cups-raw', u'application/vnd.hp-hpgl', u'application/x-cshell', u'application/x-csource', u'application/x-perl', u'application/x-shell', u'image/gif', u'image/jpeg', u'image/png', u'image/tiff', u'image/x-alias', u'image/x-bitmap', u'image/x-icon', u'image/x-photocd', u'image/x-portable-anymap', u'image/x-portable-bitmap', u'image/x-portable-graymap', u'image/x-portable-pixmap', u'image/x-sgi-rgb', u'image/x-sun-raster', u'image/x-xbitmap', u'image/x-xpixmap', u'text/css', u'text/html', u'text/plain']

Comment 11 Tim Waugh 2009-08-10 15:20:27 UTC
Yes, I think it must be some sort of memory corruption. :-(

Let's try to take a look at this "" type and see what's happened to it.

Start the debugger again and get it to attach to cupsd as before.

First find the printer:

p ((cupsd_printer_t*)Printers->elements[0])->name
p ((cupsd_printer_t*)Printers->elements[1])->name
p ((cupsd_printer_t*)Printers->elements[2])->name
...
until we find "Canon-iR-3170C-EUR".

Then look at the filetypes:

p ((cupsd_printer_t*)Printers->elements[3])->filetypes->num_elements
$14 = 28
p
*(mime_type_t*)((cupsd_printer_t*)Printers->elements[3])->filetypes->elements[27]

Here's what mine looks like:

$29 = {rules = 0x7f027e33a6a0, priority = 100, 
  super = "text", '\0' <repeats 11 times>, 
  type = "plain\0\0\0\0\0\0\0\201", '\0' <repeats 31 times>, "
\247\63~\2\177\0\0\2", '\0' <repeats 87 times>"\201, ", '\0' <repeats 15
times>"\240, \247\63~\2\177\0\0\240\246\63~\2\177\0\0\0\0\0\0\0\0\0\0\3", '\0'
<repeats 15 times>, "*.txt", '\0' <repeats 54 times>}

After that, take a brief look at the rules to see if they are intact:

p
*(*(mime_type_t*)((cupsd_printer_t*)Printers->elements[3])->filetypes->elements[27]).rules

p
*(*(mime_type_t*)((cupsd_printer_t*)Printers->elements[3])->filetypes->elements[27]).rules.child

p
*(*(mime_type_t*)((cupsd_printer_t*)Printers->elements[3])->filetypes->elements[27]).rules.child.next

Comment 12 Jiri Popelka 2009-08-10 15:40:39 UTC
Created attachment 356907 [details]
gdb output

Comment 13 Jiri Popelka 2009-08-10 16:13:54 UTC
Created attachment 356914 [details]
ddd output

Comment 14 Tim Waugh 2009-08-10 16:31:45 UTC
It's hard to read but actually that output is for the 'text/html' MIME type (even though 'plain' appears later in that string, after the nul terminator). :-(

OK, let's leave it for today and see if it happens again.

Comment 15 Jiri Popelka 2009-08-17 10:44:26 UTC
False alarm !

There's missing (100% my fault) texttopaps in my /usr/lib/cups/filter directory.
`yum reinstall paps` fixed this problem.

Closing as not a bug.

Comment 16 Tim Waugh 2009-08-17 11:11:34 UTC
Aha, that explains it.  I had been thinking it couldn't be that because the texttops filter (CUPS' own filter) would still be present... but of course our mime.confs file doesn't say to use that for text/plain.

CUPS still shouldn't advertise '' an an available document format in that situation though.

Comment 17 Jiri Popelka 2009-08-18 17:08:22 UTC
Created attachment 357832 [details]
Proposed patch

This issue is visible when line
application/octet-stream	application/vnd.cups-raw	0
in /usr/share/cups/mime/mime.convs
is uncommented, i.e.
printing of arbitrary files without the -oraw option is enabled.

Proposed patch is attached.
The number of values in p->attrs is set to `cupsArrayCount(p->filetypes) + 1`.
But it should be set to `cupsArrayCount(p->filetypes) + i`, where i is 0 or 1
according to whether mime type application/octet-stream
is (i==0) or is not (i==1) in p->filetypes.

Comment 18 Fedora Update System 2009-09-30 14:19:58 UTC
cups-1.4.1-1.fc11 has been submitted as an update for Fedora 11.
http://admin.fedoraproject.org/updates/cups-1.4.1-1.fc11

Comment 19 Fedora Update System 2009-10-01 00:06:20 UTC
cups-1.4.1-1.fc11 has been pushed to the Fedora 11 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update cups'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F11/FEDORA-2009-10152

Comment 20 Fedora Update System 2009-10-03 18:59:42 UTC
cups-1.4.1-2.fc11 has been pushed to the Fedora 11 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update cups'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F11/FEDORA-2009-10152

Comment 21 Fedora Update System 2009-10-09 03:36:46 UTC
cups-1.4.1-4.fc11 has been pushed to the Fedora 11 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update cups'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F11/FEDORA-2009-10152

Comment 22 Fedora Update System 2009-10-14 02:00:02 UTC
cups-1.4.1-4.fc11 has been pushed to the Fedora 11 stable repository.  If problems still persist, please make note of it in this bug report.