| www.delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| DKIM-Filter: | OpenDKIM Filter v2.11.0 sourceware.org 014D43858C33 |
| DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; |
| s=default; t=1692013928; | |
| bh=C977AEuPV9U/J1uBvG1l+5vc9yzOt9Zx+y47l6V21S4=; | |
| h=Subject:Date:To:List-Id:List-Unsubscribe:List-Archive:List-Post: | |
| List-Help:List-Subscribe:From:Reply-To:From; | |
| b=FYVp5Pg1gxGysfFqMbRbED3DdRE/UUvJ+l11tJXOPgsuRDdi705+ftuovLdUszDeY | |
| s5RkX7K5MjdKwNO5H7+bzmGYWfTxdFLlIc6klDFx6Qf23WiN5X27Z2rUjA8sCvENXf | |
| X+EZ3CZDtRNO3v550JdkCEwcshndqrE3lNtJHWSI= | |
| X-Original-To: | cygwin AT cygwin DOT com |
| Delivered-To: | cygwin AT cygwin DOT com |
| DMARC-Filter: | OpenDMARC Filter v1.4.2 sourceware.org 0FDA33858C1F |
| Mime-Version: | 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) |
| Subject: | Pipes truncating data in cygwin from main and cygwin-3_4-branch |
| Message-Id: | <13B0370E-B61A-44B9-A885-5FF1B8F4AC5F@callow.im> |
| Date: | Mon, 14 Aug 2023 20:51:39 +0900 |
| To: | cygwin AT cygwin DOT com |
| X-Mailer: | Apple Mail (2.3731.700.6) |
| X-OutGoing-Spam-Status: | No, score=-1.0 |
| X-AntiAbuse: | This header was added to track abuse, |
| please include it with any abuse report | |
| X-AntiAbuse: | Primary Hostname - ssd1.hungerhost.com |
| X-AntiAbuse: | Original Domain - cygwin.com |
| X-AntiAbuse: | Originator/Caller UID/GID - [47 12] / [47 12] |
| X-AntiAbuse: | Sender Address Domain - callow.im |
| X-Get-Message-Sender-Via: | ssd1.hungerhost.com: authenticated_id: |
| github AT callow DOT im | |
| X-Authenticated-Sender: | ssd1.hungerhost.com: github AT callow DOT im |
| X-Source: | |
| X-Source-Args: | |
| X-Source-Dir: | |
| X-Spam-Status: | No, score=-1.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, |
| DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, HAS_X_OUTGOING_SPAM_STAT, | |
| HTML_MESSAGE, SPF_HELO_NONE, SPF_PASS, | |
| TXREP autolearn=no autolearn_force=no version=3.4.6 | |
| X-Spam-Checker-Version: | SpamAssassin 3.4.6 (2021-04-09) on |
| server2.sourceware.org | |
| X-Content-Filtered-By: | Mailman/MimeDel 2.1.29 |
| X-BeenThere: | cygwin AT cygwin DOT com |
| X-Mailman-Version: | 2.1.29 |
| List-Id: | General Cygwin discussions and problem reports <cygwin.cygwin.com> |
| List-Archive: | <https://cygwin.com/pipermail/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-request AT cygwin DOT com?subject=help> |
| List-Subscribe: | <https://cygwin.com/mailman/listinfo/cygwin>, |
| <mailto:cygwin-request AT cygwin DOT com?subject=subscribe> | |
| From: | =?utf-8?b?44Kt44Oj44Ot44Km44CA44Oe44O844KvIHZpYSBDeWd3aW4=?= |
| <cygwin AT cygwin DOT com> | |
| Reply-To: | =?utf-8?B?44Kt44Oj44Ot44Km44CA44Oe44O844Kv?= <github AT callow DOT im> |
| Sender: | "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com> |
--===============8203364804778105002==
Content-Type: multipart/signed;
boundary="Apple-Mail=_92722B52-293D-4845-A731-8B4D3C586C74";
protocol="application/pgp-signature";
micalg=pgp-sha512
--Apple-Mail=_92722B52-293D-4845-A731-8B4D3C586C74
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=utf-8
Hi,
I have a problem that looks like pipes are truncating data when I cat a =
file to my program=E2=80=99s stdin. A simple `cat foo | cat > bar` works =
fine. bar ends up identical to foo. It is more complicated than that. My =
application is doing this
std::stringstream buffer;
buffer << std::cin.rdbuf();
std::istream* isp =3D &buffer;
Initial reads after this work fine. Once the app has read everything up =
to the payload data in the file, it does
off_t dataStart =3D (off_t)(isp->tellg());
isp->seekg(0, ios_base::end);
off_t dataEnd =3D (off_t)(isp->tellg());
dataSizeInFile =3D dataEnd - dataStart;
The tellg result shows the size is significantly less than the actual =
file data. 43k less in a 170k file. It is seemingly being truncated =
somewhere.
Later the app does
isp->seekg(0);
std::streambuf* _streambuf =3D (isp->rdbuf());
and starts reading from _streambuf. All data read from _streambuf is =
gibberish.
The application code makes no distinction between a pipe and stdin =
redirection from a file. It just uses std::cin. stdin redirection still =
works.
I created a minimal reproducer. More on that in a moment.
I first encountered this in Git for Windows 2.41.0. I had no problem in =
previous versions. I reported this to the Git for Windows project. See =
https://github.com/git-for-windows/git/issues/4464. You can find the =
minimal reproducer over there. It consists of 2 parts, a script and a =
small c++ program. The script finds the size of the target file then =
cats it to the test program passing the file size as a command line =
option. The test program does what I have described above and compares =
the file size determined from the seek to the end with the provided =
size.
A G4W project member reports that the problem reproduces on vanilla =
Cygwin in the branches mentioned in the subject and that G4W and MSYS2 =
are on the cygwin-3_4-branch release train. He recommends reporting the =
bug to you, You can find his(?) full comment here =
<https://github.com/git-for-windows/git/issues/4464#issuecomment-167113744=
6>.
I am not using cygwin directly so I can=E2=80=99t provide the output =
from `cygcheck`.
Regards
-Mark
--Apple-Mail=_92722B52-293D-4845-A731-8B4D3C586C74
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=signature.asc
Content-Type: application/pgp-signature;
name=signature.asc
Content-Description: Message signed with OpenPGP
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
iQEzBAEBCgAdFiEE7YIgIVSPLJapfaYaETbJ7D8AEGMFAmTaFUsACgkQETbJ7D8A
EGP5yQf/QOq98kjIbPQ68sfBRzX0gjJPIsY48Zexb83SA21mVIog25Hk+MZEXs0y
lTQVBnJUCbf28E29R4g1eipEDIGyuFGBsOB7JKNNK7MVRjNi1eVlC2Nw9hnCQJrj
IsBLvjX7FxCILy3/RgiCP5Pc+kFNYYyzjJGXC1JZPIYhfo7jCZG8mOSJznWC99Ps
y942JfxzrT9V6Ge7EPPDfbTIN9dfL+VADyzfp/a3KHY5jVBjb0L6nx+QUxH1vXX+
095nwt/r/MKa1qdBJkR12vlvpd3iWkitT6JAo3RszcRyXflXTaCffrUyPi6flYRb
+sX8yD+R9pE9eSk6PWPZy5xHP11E1g==
=ZYx1
-----END PGP SIGNATURE-----
--Apple-Mail=_92722B52-293D-4845-A731-8B4D3C586C74--
--===============8203364804778105002==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
--
Problem reports: https://cygwin.com/problems.html
FAQ: https://cygwin.com/faq/
Documentation: https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
--===============8203364804778105002==--
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |