stream output corrupt
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
Critical
|
Unassigned |
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 paradicsom.
*features*
(:ASDF2 :ASDF :ASDF-UNIX :SB-XREF-
:SB-DOC :SB-TEST :SB-LDB :SB-PACKAGE-LOCKS :SB-UNICODE :SB-EVAL
:SB-SOURCE-
:LARGEFILE :GENCGC :STACK-
:LINKAGE-TABLE :COMPARE-
:RAW-INSTANCE-
:STACK-
:CYCLE-COUNTER :COMPLEX-FLOAT-VOPS :FLOAT-EQL-VOPS :INLINE-CONSTANTS
:MEMORY-
:OS-PROVIDES-PUTWC :OS-PROVIDES-
:OS-PROVIDES-POLL)
Changed in sbcl: | |
status: | Fix Committed → Fix Released |
commit 40269d0ac711b36 151bec69db7a021 a28cef41ee
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 1.0.42.43, 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.