[PATCH] Initialize IO_STATUS_BLOCK for pread, pwrite

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Nov 28 09:32:00 GMT 2017


On Nov 28 00:03, Mark Geisert wrote:
> Mark Geisert wrote:
> > ---
> >  winsup/cygwin/fhandler_disk_file.cc | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
> > index 5dfcae4d9..2ead9948c 100644
> [...]
> 
> Oops, I neglected to include an explanatory comment. Issuing simultaneous
> pwrite(s) on one file descriptor from multiple threads, as one might do in a
> forthcoming POSIX aio implementation, sometimes results in garbage status in
> the IO_STATUS_BLOCK on return from NtWriteFile(). Zeroing beforehand made
> the issue go away.
> 
> This is mildly concerning to me because there are many other uses of
> IO_STATUS_BLOCK in the Cygwin DLL that haven't seemed to have needed
> initialization.
> 
> Puzzledly,

Ok, let's start with, why did you tweak pread if you only observed
a problem in pwrite?  In terms of pread, we already have a very recent
patch series:

https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=46702f92ea49
https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=c983aa48798d
https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=181fe5d2edac

In this case it turned out that the problem was related to hitting EOF.
I wonder if we hit a similar problem here.

Two points:

- Did you check the status code returned by NtWriteFile?  Not all non-0
  status codes fail the !NT_SUCCESS (status) test.

- Do you have a simple, self-contained testcase?


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20171128/953fff06/attachment.sig>


More information about the Cygwin-patches mailing list