Mac OS X 10.11.3: libdispatch's dispatch_io_write can succeed and signal an ECANCELED error

Originator:weissismail
Number:rdar://24504260 Date Originated:04-Feb-2016 04:43 PM
Status:Open Resolved:
Product:OS X Product Version:Mac OS X 10.11.3 (15D21)
Classification:Serious Bug Reproducible:Always
 
Summary:

libdispatch's dispatch_io_write sometimes calls its handler block with (true, 0x7fff72149b50, 89) which as of the documentation means "unrecoverable error, ECANCELED". This can even happen if it was successful, ie the bytes were already read at the other end.

Steps to Reproduce:

1. Compile the attached program with 'clang -o test test.c'
2. Run it in a loop with 'while true; do ./test 2>&1 | grep -C5 ERROR; done'

Expected Results:

should produce no output as there should be no failures.


Actual Results:

Sometimes outputs the following:
--- SNIP ---
=== BEGIN ===
buf='hallo
'
on it
ERROR: 1, 0x7fff72149b50, 89
===  END  ===
--- SNAP ---

from buf='hallo\n' we see that the data was successfully written (and read on the other side). However from 'ERROR: 1, 0x7fff72149b50, 89' we learn that the dispatch_io_write failed even though it succeeded :).

Regression:
don't know but probably not

Notes:
n/a

Comments

test.c

The file attached to the Radar can be found here: https://gist.github.com/weissi/fa6d59ea3e71d276b7c5

By weissismail at Feb. 4, 2016, 4:48 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!