stream output corrupt

Bug #820599 reported by Robert Brown on 2011-08-03
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

SBCL writes the wrong data to output streams when write(2) returns a smaller value
than the total number of bytes requested. I see the problem with I/O to socket streams
where the stream has serve-event equal to NIL.

The bug is in flush-output-buffer in file fd-stream.lisp.
When sb!unix:unix-write returns a value for count that is less than length,
the code loops and tries to write again after waiting for the file descriptor
to become usable. The length for the second write is recomputed
as (- tail head), but head has not been changed to account for the data
already written. The attached patch fixes the problem.

sbcl --version
SBCL 1.0.50

uname -a
Linux 2.6.32-gg508-generic #gg508-Ubuntu SMP Tue May 24 05:09:12 PDT 2011 x86_64 GNU/Linux



Robert Brown (robert-brown) wrote :
  • p Edit (653 bytes, text/plain)
Nikodemus Siivola (nikodemus) wrote :

commit 40269d0ac711b36151bec69db7a021a28cef41ee
Author: Nikodemus Siivola <email address hidden>
Date: Thu Aug 4 13:31:06 2011 +0300

    fix short writes when not using SERVE-EVENT

      Regression since, lp#820599.

      Thanks to Robert Brown.

      If we remain in the loop, we need to update the local HEAD
      variable in the event of a short write.

      NOTE: No test case yet, as this is dependant on the size of kernel
      buffers, and trying to catch the short-write -case is tricky.

Changed in sbcl:
importance: Undecided → Critical
status: New → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers