Bug 9698 - Print data corruption
Summary: Print data corruption
Status: RESOLVED WORKSFORME
Alias: None
Product: Samba 3.5
Classification: Unclassified
Component: Printing (show other bugs)
Version: 3.5.16
Hardware: PPC Linux
: P3 normal
Target Milestone: ---
Assignee: printing-maintainers
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-05 01:58 UTC by Dheeraj Reddy (dead mail address)
Modified: 2021-01-08 00:33 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dheeraj Reddy (dead mail address) 2013-03-05 01:58:12 UTC
1) Samba print server running on Linux OS on PPC Hardware.
2) Fire print jobs(400KB) at and interval of 15 seconds continuously(without stop for hours) to Samba Print server from Windows XP/Windows 7 machine.
3) Collect the data at "print_job_write" function of "source3/printing/printing.c" file.
4) compare original sent data already copied to Linux with the data received from samba.
5) At a frequency of 1/300. print data is getting corrupted. 128KB of data which need to be present at end is shifted to middle of file created by samba.

Can you please check why this data corruption is happening in samba.
Comment 1 David Disseldorp 2013-03-06 15:28:52 UTC
Please provide level 10 Samba logs captured across corrupted print job submission.
Are able to run the same test against a non-PPC architecture machine?
Comment 2 Dheeraj Reddy (dead mail address) 2013-03-07 07:24:37 UTC
David, thanks for your quick reply.
I had found out the issue.
This is because of "pos" argument of "print_job_write" function in "source3/printing/printing.c". Normally chunks of data received by samba are sequential(EX:1,2,3,4,5,6,7). At some time even though chunks of data received by samba are serial(EX:1,2,3,4,5,6,7). flow of chunks to printing/printing.c(print_job_write) is getting varied(EX:1,2,3,7,4,5,6). Actually in this case samba is properly setting pos value as middle or end of file. But wrapper which I have written dose not consider pos variable and assumes that samba always sends data sequentially. So this is the cause of this issue. 
I have following questions regarding this:

1) When I had verified samba 3.6.12 code it is observed that this pos variable is removed. Is this variable removed from samba 3.6.12 because of some issue? 
2) And my major doubt is In which scenario does samba modify the flow of data chunks received(EX:1,2,3,4,5,6,7   to   1,2,3,7,4,5,6,)?
3) Does shifting to 3.6.12 solve this issue for me?


Info: As I do not write data received at "print_job_write" function to a file but directly spool the chunks of data, I am facing corruption in print data.
Comment 3 David Disseldorp 2013-03-07 10:49:02 UTC
(In reply to comment #2)
> David, thanks for your quick reply.
> I had found out the issue.
> This is because of "pos" argument of "print_job_write" function in
> "source3/printing/printing.c". Normally chunks of data received by samba are
> sequential(EX:1,2,3,4,5,6,7). At some time even though chunks of data received
> by samba are serial(EX:1,2,3,4,5,6,7). flow of chunks to
> printing/printing.c(print_job_write) is getting varied(EX:1,2,3,7,4,5,6).
> Actually in this case samba is properly setting pos value as middle or end of
> file. But wrapper which I have written dose not consider pos variable and
> assumes that samba always sends data sequentially. So this is the cause of this
> issue. 

So if I understand correctly, you're implying that the bug is in your test code or Samba modification, which assumes sequential calls to print_job_write()? 

How exactly is your client initiating the print job, via smbd (create&X/write&X etc.), or via spoolss RPCs (StartDocPrinter/WritePrinter)? AFAICT the client may only specify a job offset when printing via smbd, WritePrinter RPCs are always handled sequentially.

> I have following questions regarding this:
> 
> 1) When I had verified samba 3.6.12 code it is observed that this pos variable
> is removed. Is this variable removed from samba 3.6.12 because of some issue?

The pos variable was removed as it was no longer used, see commit 3aba8e9b7e1feb3a429dfa8e68fb00b61e985ffd. Printing code paths underwent large changes between 3.5.x and 3.6.x. One such change was to separate print job IO handling between spoolss and smbd. print_job_write() is now only called in the spoolss WritePrinter code path, which does not take a job write-offset.
 
> 2) And my major doubt is In which scenario does samba modify the flow of data
> chunks received(EX:1,2,3,4,5,6,7   to   1,2,3,7,4,5,6,)?

As previously described, this is dependent on client behaviour.

> 3) Does shifting to 3.6.12 solve this issue for me?
> 
> 
> Info: As I do not write data received at "print_job_write" function to a file
> but directly spool the chunks of data, I am facing corruption in print data.

I can't answer this question without knowing how you're interfacing with Samba.
Comment 4 Björn Jacke 2021-01-08 00:33:09 UTC
Dheeraj: I'm closing this bug because I assume that the problem doesn't exist in newer version. I would still like to hear feedback from you if it's working fine for you or if you found out more on this issue. Also details about the configuration would still be intersting.