[Mono-bugs] [Bug 531613] New: System.Diagnostics.Process StandardInput stream doesn't handle short writes properly

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Aug 17 01:16:56 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=531613


           Summary: System.Diagnostics.Process StandardInput stream
                    doesn't handle short writes properly
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.4.x
          Platform: i686
        OS/Version: Linux
            Status: NEW
          Severity: Critical
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: brian at sooloos.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US;
rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2

System.Diagnostics.Process uses FileStream to implement the standard input
stream of a child process. FileStream seems to make an assumption that
MonoIO.Write either fails or writes the whole buffer. This assumption fails
when FileStream is used with a pipe fd if the kernel writes only part of the
buffer to the pipe.

I diagnosed this using strace--I was doing a series of 32k writes to the
System.Diagnostics.Process.StandardInput.BaseStream of a child process, and saw
that immediately after one of the writes came back short, data was being seen
as corrupted by the child process. The strace looked roughly like this:

..
write(14, ..., 32768) => 32768
write(14, ..., 32768) => 32768
write(14, ..., 32768) => 20480
write(14, ..., 32768) => 32768
write(14, ..., 32768) => 32768

It's pretty clear from this that 12288 bytes are missing from the third write.
I confirmed this by looking at data dumps from the send + receive side--sure
enough, exactly 12288 bytes are missing from the end of one of the 32k blocks
of data on the recieve side, but not on the send side.

Looking at the code in WriteInternal and FlushBuffer in
mcs/class/corlib/System.IO/FileStream.cs, it's clear why: MonoIO.Write returns
the number of bytes written, but it isn't being used/acted upon in this code.


Reproducible: Always




I've marked this as critical because it causes significant and
non-deterministic data loss in communication between parent and child
processes.

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list