Bug 9698 - Print data corruption
Print data corruption
Status: NEW
Product: Samba 3.5
Classification: Unclassified
Component: Printing
3.5.16
PPC Linux
: P3 normal
: ---
Assigned To: printing-maintainers
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-05 01:58 UTC by Dheeraj Reddy
Modified: 2013-03-07 10:49 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dheeraj Reddy 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 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.