delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2015/08/15/07:12:55

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:reply-to:from:date:message-id
:subject:to:content-type; q=dns; s=default; b=YdP0VZtbWA8Mpuc2kW
LnzO0QDHsoo4XFZ57GOo9Rcq7XOMDQumC71vBjhr0HPDDv3g9yCr/DrtWY09YdXb
l2rXPt4i9/4nZUsxakAafSIwIDlEyiq8K+3uu+akcV7pun08oa9EySsQx/c8KhhF
CJfRKSygAFjLSnU4aBtOswYFo=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:reply-to:from:date:message-id
:subject:to:content-type; s=default; bh=h/Uzu8MiKmd97Yit8XVzj2o5
QJ0=; b=gVcZ78OwMkuDNnYKzlwQ5x4I2B9IkwMU9PWnkfIeddtBGArW9krrYW99
cAorNLmrzFK3Ja+T1Ttqw2d9OZdeDWHVzn/82P4apTanjJDa+Vg46yDdinJlRH7x
NuAlxRJUuky3U7g/8dZgvT773PHLeu+nBUvFQSYn8Z/ITaVoMSE=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=1.1 required=5.0 tests=AWL,BAYES_05,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,UNSUBSCRIBE_BODY autolearn=no version=3.3.2
X-HELO: mail-wi0-f173.google.com
X-Received: by 10.194.179.37 with SMTP id dd5mr8912074wjc.129.1439637153998; Sat, 15 Aug 2015 04:12:33 -0700 (PDT)
MIME-Version: 1.0
Reply-To: fracting AT gmail DOT com
From: Qian Hong <fracting AT gmail DOT com>
Date: Sat, 15 Aug 2015 19:11:54 +0800
Message-ID: <CALd+sZSJeQVmhtwfPSXxQtWTYfVvFh_ikxZL2p0Jo4thBwykuQ@mail.gmail.com>
Subject: Cygwin on Wine: changing buffer content immediately after aync write() to a pipe corrupts written result
To: cygwin <cygwin AT cygwin DOT com>
X-IsSubscribed: yes

--089e013d1d3c2ba6fc051d57a529
Content-Type: text/plain; charset=UTF-8

Dear list,

Recently we are investigating a Wine (Wine Staging) bug encountered by
Cygwin/MSYS2, which also suggest a potential bug in Cygwin.

When running xz on Cygwin/MSYS2 on Wine to decompress data and write
to a pipe, we found data corruption in the final result. This is
reported as Wine Staging bug 394:

https://bugs.wine-staging.com/show_bug.cgi?id=394

The command line to reproduce the bug is below:
$ cd /usr/share/gettext
$ xz -d -c < archive.dir.tar.xz | sha1sum # output result is random on Wine

Tested version:

Cygwin version
2.1.0, 2015/07/14 C:\cygwin\bin\cygwin1.dll

XZ version
$ xz --version
xz (XZ Utils) 5.2.1
liblzma 5.2.1

Wine Staging:
$ wine --version
wine-1.7.49-717-g3404140 (Staging)

In case anyone interesting, we also tested on msys2:
MSYS_NT-5.1  2.2.1(0.289/5/3) 2015-08-09 14:43 i686 Msys

***

With help from Lazhu (xz developer), Corrina and Sebastian, the
problem become a bit clearer. For archive, here are some testing
results we got:


1. This problem can't be reproduce on WinXP or Win7 according to my tests.

2. This problem doesn't happen with xz 5.0.8. Lazhu pointed out a
relate issue which doesn't happen in xz 5.0.8 but discovered by 5.2.1:
https://cygwin.com/ml/cygwin/2015-02/msg00575.html

That's very helpful information, finally we made sure the two problem
are different but get a clear idea what might be wrong.

3. Modified from Lazhu's previous test case, we wrote a new test case
to simulate the new problem, as attachment writer.c:
$ gcc writer.c -o writer
$ ./writer | sha1sum # the result is randomly on Wine but constant on Windows

The test case reproduce the problem on Wine, which generate randomly sha1sum.

If pipe is not used, then there is no data corruption:
$ ./write > good.txt && sha1sume good.txt # always good on Wine and Windows

However, the same test case doesn't reproduce anything wrong on WinXP
and Win7, sha1sum is always constant.

I tried modified buffer size, loop counts, etc inside the test case, I
also made sure EAGAIN is trigger on both Wine and Windows. I also
tried something like below to slow down reader speed:
$ ./write | pv -L512k | sha1sume

In any case, it's 100% reproduce on Wine, but never reproduce on Windows.

***

We are going to do some more test, will update this thread when we
have something interesting.

Thanks.


-- 
Regards,
Qian Hong

-
http://www.winehq.org

--089e013d1d3c2ba6fc051d57a529
Content-Type: text/x-csrc; charset=US-ASCII; name="writer.c"
Content-Disposition: attachment; filename="writer.c"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_idcwzj6m0

Ly8gZ2NjIC1zdGQ9Z251OTkgLVdhbGwgLVdleHRyYSB3cml0ZXIuYyAtbyB3
cml0ZXIKCiNpbmNsdWRlIDxzeXMvdHlwZXMuaD4KI2luY2x1ZGUgPHN5cy9z
dGF0Lmg+CiNpbmNsdWRlIDxmY250bC5oPgojaW5jbHVkZSA8dW5pc3RkLmg+
CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNs
dWRlIDxzdHJpbmcuaD4KI2luY2x1ZGUgPGVycm5vLmg+CgpzdGF0aWMgdm9p
ZApmYWlsKGNvbnN0IGNoYXIgKnN0cikKewoJZnByaW50ZihzdGRlcnIsICJX
OiAlc1xuIiwgc3RyKTsKCWV4aXQoRVhJVF9GQUlMVVJFKTsKfQoKaW50Cm1h
aW4odm9pZCkKewoJaW50IGZsYWdzID0gZmNudGwoU1RET1VUX0ZJTEVOTywg
Rl9HRVRGTCk7CglpZiAoZmxhZ3MgPT0gLTEpCgkJZmFpbCgiQ2Fubm90IGdl
dCBzdGRvdXQgZmlsZSBzdGF0dXMgZmxhZ3MiKTsKCglpZiAoZmNudGwoU1RE
T1VUX0ZJTEVOTywgRl9TRVRGTCwgZmxhZ3MgfCBPX05PTkJMT0NLKSA9PSAt
MSkKCQlmYWlsKCJTZXR0aW5nIHN0ZG91dCB0byBub24tYmxvY2tpbmcgbW9k
ZSBmYWlsZWQiKTsKCglzdGF0aWMgdW5zaWduZWQgY2hhciBidWZbNjQgPDwg
MTBdOwoJaW50IGJsb2NraW5nID0gMDsKCWludCBpID0gMDsKCgl3aGlsZSAo
aSA8IDI1NikKCXsKCQlpbnQgcmV0ID0gd3JpdGUoU1RET1VUX0ZJTEVOTywg
YnVmLCBzaXplb2YoYnVmKSk7CgkJaWYgKHJldCA9PSAtMSAmJiBlcnJubyA9
PSBFQUdBSU4pCgkJewoJCQlibG9ja2luZysrOwoJCQljb250aW51ZTsKCQl9
CgoJCWlmIChyZXQgIT0gc2l6ZW9mKGJ1ZikpCgkJCWZhaWwoIlVuZXhwZWN0
ZWQgbnVtYmVyIG9mIGJ5dGVzIik7CgoJCW1lbXNldChidWYsICsraSwgc2l6
ZW9mKGJ1ZikpOwoJfQoKCWlmICghYmxvY2tpbmcpCgkJZmFpbCgiV2FzIG5l
dmVyIGJsb2NraW5nLCByZWFkIHdhcyB0b28gZmFzdCIpOwoKCWlmIChmY250
bChTVERPVVRfRklMRU5PLCBGX1NFVEZMLCBmbGFncykgPT0gLTEpCgkJZmFp
bCgiUmVzdG9yaW5nIHN0ZG91dCBmaWxlIHN0YXR1cyBmbGFncyBmYWlsZWQi
KTsKCglpZiAoY2xvc2UoU1RET1VUX0ZJTEVOTykpCgkJZmFpbCgiRXJyb3Ig
Y2xvc2luZyBzdGRvdXQiKTsKCglyZXR1cm4gRVhJVF9TVUNDRVNTOwp9Cg==


--089e013d1d3c2ba6fc051d57a529
Content-Type: text/plain; charset=us-ascii

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
--089e013d1d3c2ba6fc051d57a529--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019