-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
This issue is about a problem with pipes in the Bash / MingW(?) / MSYS(?) included with 2.41.0. Is this the right place to report such an issue? If not, where should I report it and how to I find the relevant version information to included with the report?
Setup
- Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options
git version 2.41.0.windows.1
cpu: x86_64
built from commit: ff94e79c4724635915dbb3d4ba38f6bb91528260
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
- Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver
Microsoft Windows [Version 10.0.22621.1702]
- What options did you set as part of the installation? Or did you choose the
defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
> type "$env:USERPROFILE\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt
Editor Option: CustomEditor
Custom Editor Path: "C:\Program Files\Vim\vim90\gvim.exe"
Default Branch Option: main
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Merge
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Enabled
Enable Pseudo Console Support: Enabled
Enable FSMonitor: Disabled
- Any other interesting things about your environment that might be related
to the issue you're seeing?
No. I've seen it on my own machine and on 2 different CI runners.
Details
- Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other
Bash and PowerShell.
- What commands did you run to trigger this issue? If you can provide a
Minimal, Complete, and Verifiable example
this will help us understand the issue.
$ cat color_grid_uastc_zstd.ktx2 | ktx2checkI have not yet been able to create a simple reproducer
- What did you expect to occur after running these commands?
I expected ktx2check to tell me the file was valid.
- What actually happened instead?
ktx2check told me the file did not have the expected byte count of image data and then told me it wasn't a KTX file.
- If the problem was occurring with a specific repository, can you provide the
URL to that repository to help us with testing?
This is not repo related.
What this is really all about
Now the, in this instance not very helpful, boilerplate is out of the way here are the gory details.
Pipes between bash processes are not working correctly. New in 2.41.0. All worked fine in Git for Windows 2.40.1.windows.1 and all previous that I've used. The problem appeared in our GitHub workflows builds on the VS2019 and VS 2022 runners after Git was updated to 2.41.0.
A simple cat foo | cat > bar works fine. bar ends up identical to foo. It is more complicated than that. My application ktx2check is doing this
// Read entire pipe content into buffer as seek does not work on this cin
std::stringstream buffer;
buffer << std::cin.rdbuf();
std::istream* isp = &buffer;
Reads after this all work fine. Once the app has read everything up to payload data it does
off_t dataStart = (off_t)(isp->tellg());
isp->seekg(0, ios_base::end);
if (ctx.inp->fail())
addIssue(logger::eFatal, IOError.FileSeekEndFailure,
strerror(errno));
off_t dataEnd = (off_t)(isp->tellg());
dataSizeInFile = 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 = (isp->rdbuf());
and starts reading from _streambuf. All data read from the streambuf is gibberish leading to the not a KTX file message.
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 won't have time to try to create a minimal reproducer for several more days. Sorry for that. I am hoping somebody else will recognize the symptoms.