Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whole team gets 'inflate returned -5' when cloning a specific repo on Windows #1848

Closed
raggot opened this issue Sep 24, 2018 · 40 comments
Closed

Comments

@raggot
Copy link

raggot commented Sep 24, 2018

My team and I have a private repository hosted on GitLab. We have had some issues with it lately, and after some testing and hacking, we ended up realising we seem not to be able to clone from origin on Windows, but we can on Ubuntu.

I have posted a detailed question on Stack Overflow about the issue we have, so I won't repeat myself, but very briefly, this is what we get when trying to clone:

$ git clone [email protected]:rbionics/msd/msd-source-legacy-test.git
Cloning into 'msd-source-legacy-test'...
Enter passphrase for key '/c/Users/Username/.ssh/id_rsa':
remote: Enumerating objects: 3749, done.
remote: Counting objects: 100% (3749/3749), done.
remote: Compressing objects: 100% (1393/1393), done.
fatal: pack has bad object at offset 25651765: inflate returned -5
fatal: index-pack failed

I read on some other websites that in the past this was associated to a bug in Git. I wonder if it's possible, as in Ubuntu everything seems to work.

Thanks in advance for your time.

@PhilipOakley
Copy link

Would you be able to complete the additional version info (etc) that is in the template, including windows version.

Have you tried to create a local server with a bare repository, as a test, that can then be used to verify if this is synchronisation issue with the GitLab server.

If you can regain control & integrity locally, it maybe that you can then clear (by branch deletion) the destination repo, and then push the local clean copy.

If this is Windows only then there may still be extra things that the GfW fork needs to resolve.

@raggot
Copy link
Author

raggot commented Sep 25, 2018

Good morning/evening Philip,

First of all, here's the info from the template:

$ git --version --build-options
git version 2.19.0.windows.1
cpu: x86_64
built from commit: d96bb8bc6c636a8869140e860e72e7bdf64bd790
sizeof-long: 4
sizeof-size_t: 8

Suspecting it might have been a recent update issue, I also tested versions 2.18 and 2.9, but the outcome was the same.

I am using Windows 10 (64-bit)

$ cmd.exe /c ver
Microsoft Windows [Version 10.0.17134.285]

Content of C:\Program Files\Git\etc\install-options.txt (default):

Editor Option: VIM
Path Option: Cmd
SSH Option: OpenSSH
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled
Enable Builtin Rebase: Disabled
Enable Builtin Stash: Disabled

I liked the suggestion of cloning from another server. I actually did not setup another server, but instead copy-pasted the repository on a USB stick. I entered a folder on my C: drive and used Git Bash to git clone E:\repo successfully. So, at least "locally" it looks like I am able to clone.

Could it be a Git+Gitlab+Windows problem? Or perhaps a Git+SSH+Windows problem?

To quickly answer the other suggestions, after regaining local control of my repository, I already tried to make a fresh remote on GitLab (new blank project to which I pushed all branches of our repo), but the problem persisted. I also tried to create a new project and push from a colleague's computer, doubting the issue might have been related to my local repo or some local configurations. Same story.

Once again, on Ubuntu it looks like nothing is broken anymore and everybody can work normally.

Thanks!

@dscho
Copy link
Member

dscho commented Dec 26, 2018

Closing, due to continued lack of an MCVE.

I will reopen once one is available.

@dscho dscho closed this as completed Dec 26, 2018
@ribalda
Copy link

ribalda commented Mar 28, 2019

Having the same issue here with

cmd.exe /c ver
Microsoft Windows [Version 10.0.17763.379]
C:\Qtec_GIT\legacy\svn.qtec.com\components\HW_QT5122_APU>git --version --build-options
git version 2.21.0.windows.1
cpu: x86_64
built from commit: 2481c4cbe949856f270a3ee80c802f5dd89381aa
sizeof-long: 4
sizeof-size_t: 8

Also from Gitlab. In Linux it works fine, in windows I am getting

remote: Enumerating objects: 2319, done.
remote: Counting objects: 100% (2319/2319), done.
remote: Compressing objects: 100% (1173/1173), done.
fatal: pack has bad object at offset 321192944: inflate returned -5
fatal: index-pack failed

git fetch --depth=1
works fine,
but
git fetch --depth=41 fails

I checked on my linux computer, and it seems to be a commit that adds a 4.2G data. Other commits then remove that one.

So it might be related to a file size. I will try to work on a MCVE.

@dscho, could you please reopen this.

@ribalda
Copy link

ribalda commented Mar 28, 2019

I think that I got it.

Please try to clone: https://gitlab.com/ricardo.qtec/bug-gitwin

git.exe clone --progress -v "[email protected]:ricardo.qtec/bug-gitwin.git" "C:\Qtec_GIT\bug-gitwin"

Cloning into 'C:\Qtec_GIT\bug-gitwin'...
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 7 (delta 1), reused 0 (delta 0)
fatal: pack has bad object at offset 616: inflate returned 1
fatal: index-pack failed


git did not exit cleanly (exit code 128) (39016 ms @ 28/03/2019 16:39:49)

@ribalda
Copy link

ribalda commented Mar 28, 2019

Cloning from my linux computer via ssh also fails, so we cannot blame gitlab for this.

git.exe clone --progress -v "ssh://192.168.2.11/tmp/bug-gitwin" "C:\Qtec_GIT\bug-gitwin"

Cloning into 'C:\Qtec_GIT\bug-gitwin'...
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 7 (delta 1), reused 1 (delta 0)
fatal: pack has bad object at offset 616: inflate returned 1
fatal: index-pack failed


git did not exit cleanly (exit code 128) (32563 ms @ 28/03/2019 16:43:43)

@tboegi
Copy link

tboegi commented Mar 28, 2019

Looks like the famous "unsigned long" problem.
bigfile was added (size 5000000000 bytes) and removed.

However, @ribalda : Which linux did you use ? 32 bit or 64 bit ?

And @raggot my suggestion would be to remove the bigfile(s) from your
repo with git-filter branch running under 64 bit Linux (Or Mac)

@ribalda
Copy link

ribalda commented Mar 28, 2019

@tboegi : Debian testing amd64.

The "unsigned long" issue is something planned to fix?
Any magic git filter to list big files across the whole repo, so I can delete them?

Thanks!

@tboegi
Copy link

tboegi commented Mar 28, 2019

I was may be too fast here with the "unsigned long", more investigation is needed.
Cloning using a 32bit raspi yields:
Cloning into 'rasp'...
warning: redirecting to https://gitlab.com/ricardo.qtec/bug-gitwin.git/
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (5/5), done.
error: inflate returned -5/7)
fatal: unpack-objects failed
That is not ideal, but nobody seem to have cloned such a repo to a 32 bit system yet.

Could someone test
https://github.com/t-b/git/tree/tb.190104_0635_convert_size_t_only_git_master_181124_mk_size_t

@ribalda
Copy link

ribalda commented Mar 28, 2019

@tboegi I can test it tomorrow at work if you provide me a binary. I have no build environment on that computer. (It is just used to run Altium).

Also I do not have windows at home

@dscho
Copy link
Member

dscho commented Mar 29, 2019

Could someone test
https://github.com/t-b/git/tree/tb.190104_0635_convert_size_t_only_git_master_181124_mk_size_t

Doesn't fix it:

Cloning into 'bug-gitwin'...
warning: templates not found in /mingw64/share/git-core/templates
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (5/5), done.
error: inflate returned -5/7)
fatal: unpack-objects failed

@dscho
Copy link
Member

dscho commented Mar 29, 2019

I could imagine that the problem lies elsewhere:

$ git -c fetch.unpackLimit=1 clone https://gitlab.com/ricardo.qtec/bug-gitwin.git/
Cloning into 'bug-gitwin'...
warning: templates not found in /mingw64/share/git-core/templates
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 7 (delta 1), reused 0 (delta 0)
fatal: pack has bad object at offset 616: total_out 5000000000, size 705032705
fatal: index-pack failed

@dscho
Copy link
Member

dscho commented Mar 29, 2019

(Note that 705032705 is precisely the difference between 5000000000 and the largest number that can be represented by a 32-bit unsigned long.)

@dscho
Copy link
Member

dscho commented Mar 29, 2019

To accelerate the inner loop, clone this MCVE (thank you for this @ribalda!!!) in WSL, then copy over the pack from .git/objects/pack/, and run git index-pack pack-*.pack in a debugger.

@dscho
Copy link
Member

dscho commented Mar 29, 2019

@dscho
Copy link
Member

dscho commented Mar 29, 2019

dscho referenced this issue in t-b/git Mar 29, 2019
Currently the length of data which is stored in memory is stored
in "unsigned long" at many places in the code base.
This is OK when both "unsigned long" and size_t are 32 bits,
(and is OK when both are 64 bits).
On a 64 bit Windows system am "unsigned long" is 32 bit, and
that may be too short to measure the size of objects in memory,
a size_t is the natural choice.

Improve the code base in "small steps", as small as possible.
The smallest step seems to be much bigger than expected.
See this code-snippet from convert.c:
        const char *ret;
        unsigned long sz;
        void *data = read_blob_data_from_index(istate, path, &sz);
        ret = gather_convert_stats_ascii(data, sz);

The corrected version looks like this:
        const char *ret;
        size_t sz;
        void *data = read_blob_data_from_index(istate, path, &sz);
        ret = gather_convert_stats_ascii(data, sz);

However, when the Git code base is compiled with a compiler that
complains that "unsigned long" is different from size_t, we end
up in this huge patch, before the code base cleanly compiles.

Signed-off-by: Torsten Bögershausen <[email protected]>
@dscho
Copy link
Member

dscho commented Mar 29, 2019

@tboegi do you have any time resources to clean up the patches in @t-b's two branches?

@ribalda
Copy link

ribalda commented Mar 29, 2019

Friendly reminder: The issue is still marked as closed. Shouldn't we reopen it?

Thanks for you help looking into this

@dscho dscho reopened this Mar 29, 2019
@dscho
Copy link
Member

dscho commented Mar 29, 2019

@ribalda of course! Thanks for noticing (and pointing it out).

@tboegi
Copy link

tboegi commented Mar 29, 2019

Seriously, I think that zlib needs a patch to replace unsigned long with size_t everywhere,
And the removal of the check done here
t-b@aec5cd5
is not what I would recommend.

And, if you want a later version of size_t branch, you can find it here:
https://github.com/tboegi/git/tree/tb.190316_1032_convert_size_t_only_git_master_181124_mk_size_t

@PhilipOakley
Copy link

I've been having a look at the issue since Git-Merge after Thomas Braun suggested a test case and a few other things. #

One also has to be very careful about "implementation defined" aspects to upcast anything that may be coerced into a 32bit long where a 64bit size_t is needed (plus all the different names for these types..)

See https://github.com/PhilipOakley/git/tree/size_t2 for my extra hacks. (it's on top of the rebased to latest gfw tb series)

also gitgitgadget#115 I may get more time tonight to further debug the added big file with 5,100 blocks of 1Mbyte, and compare it with the WSL version (byte by byte!, using HxD).

Also will need a suitable bug return code if there is an attempt to extricate a >4Gb file on a 32bit system

@dscho
Copy link
Member

dscho commented Apr 1, 2019

Seriously, I think that zlib needs a patch to replace unsigned long with size_t everywhere,

I am fairly certain that such a change would break backwards compatibility rather badly.

@PhilipOakley
Copy link

(tboegi) Seriously, I think that zlib needs a patch to replace unsigned long with size_t everywhere,

(dscho) I am fairly certain that such a change would break backwards compatibility rather badly.

not exactly sure which bits of backward compatibility you were meaning, but I'd agree that a simplistic type replacement won't do as expected because that fails to change the zlib library, where the original uInt incompatibility lay.

I also noted that crc32() which is used for packfile checking (an other places.?) also has a potential uInt length problem.

I did find that, for instance, the git_inflate_end function which bookends the zlib is in 23 places, so there are plenty of places for things to go wrong.

It's a big problem, though the early work on the majority change to size_t has been very useful!

@PhilipOakley
Copy link

Just cross checking:
section VI: http://zlib.net/manual.html#Constants
#define Z_BUF_ERROR (-5)

Still to deep read what/why/how that error comes from.. (listed 20+ times in the manual..)

@PhilipOakley
Copy link

@ribalda had a look at the https://gitlab.com/ricardo.qtec/bug-gitwin/tree/master

I had to clone it via WSL, then looked at the repo via both GfW and WSL.

Used the simple (from SO https://stackoverflow.com/a/42544963/717355)

git rev-list --objects --all \
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)'

and got (extracting the two differing lines)

blob 41ba8fda505291b7403d5aa7da0555bf04de80a2 705032704 bigfile <- windows answer
blob 41ba8fda505291b7403d5aa7da0555bf04de80a2 5000000000 bigfile <- WSL answer

At least tracing the cat-file --batch-check should give me a single point of failure for reading the length of bigfile. And whether it is from the blob's length field (and hence maybe the value placed in the index) or from the zlib inflating.

@PhilipOakley
Copy link

A bit more hand tracing of the code led to the read_object call in sha1-file.c which has a pointer unsigned long *size parameter. Which then leads onto the data struct https://github.com/git/git/blob/master/sha1-file.c#L203

static struct cached_object {
    struct object_id oid;
    enum object_type type;
    void *buf;
    unsigned long size;
} *cached_objects;

so the data caches don't even store the full 64 bit sizes (on Windows)!

There are 23 functions in sha1-file.c that would need their size/len fields changing, with a few more spots for internal variables making 33 just there. I guess the usage cascade will be quite large!

@tboegi
Copy link

tboegi commented Apr 2, 2019

@PhilipOakley : Are you sitting on the master branch ?
Please feel free to have a look here:
https://github.com/tboegi/git/blob/tb.190316_1032_convert_size_t_only_git_master_181124_mk_size_t/sha1-file.c#L203

@PhilipOakley
Copy link

PhilipOakley : Are you sitting on the master branch ?
Please feel free to have a look here:
https://github.com/tboegi/git/blob/tb.190316_1032_convert_size_t_only_git_master_181124_mk_size_t/sha1-file.c#L203

@tboegi I had thought I been on that branch (via details Thomas Braun provided) and rebased the changes to my GfW master version, then added my own extra changes.

I will check again about the various merge points (doesn't help on GfW that one has / can have multiple installs, so command history can easily be lost)

@PhilipOakley
Copy link

@tboegi Yes it looks like I was mistaken.

Could you summarise what is in (and not in) your branch - is the goal just a simple conversion to size_t alone (without code changes), or maybe just with fixing of printf syntax, or have you included a few selected code changes?
I ask so that I' not chasing the wrong problems (again?), or misunderstanding what has been fixed (maybe differently)

@PhilipOakley
Copy link

@tboegi also, How do you manage the distinction between the upstream Git (WSL compilable) and the GfW (sdk compilable) code.

@tboegi
Copy link

tboegi commented Apr 2, 2019

The printing of variables is already fixed in an earlier commit, (upcast to intmax_t).
Commit
tboegi@f510df8
fixes all "unsigned long" issues, which are known to me, up to the commit on git.git/master,
where I started.
(And actually the branch was rebased a couple of times.)
I don't know what WSL is.
We can compile git.master under GfW.

@dscho
Copy link
Member

dscho commented Apr 2, 2019

I don't know what WSL is.

Philip refers to the "Windows Subsystem for Linux", a way to run Linux programs on top of the Windows kernel. That feature also is known as "Bash on Ubuntu on Windows", although it's much more than that by now.

and got (extracting the two differing lines)

blob 41ba8fda505291b7403d5aa7da0555bf04de80a2 705032704 bigfile <- windows answer
blob 41ba8fda505291b7403d5aa7da0555bf04de80a2 5000000000 bigfile <- WSL answer

@PhilipOakley I fear you replicated my investigation that led to the discussion at t-b@7557481#r32961730 (which reflects my finding that changing the data type of c in index-pack.c and unpack-objects.c fixed the problem reported over here).

@PhilipOakley
Copy link

hi @dscho thanks for clarifying that WSL is shorthand for Windows Subsystem for Linux - I'd forgotten my NUA rule (No Unnamed Abbreviations 😉 ).

Torsten (@tboegi) also mentioned the 'We can compile git.master under GfW' (Git-for-Windows) which I think I've also seen you say. I'm not clear on what that means/implies?

I could see that it might be reasonable to get a clean compile of upstream git/master from the GfW SDK, but I wasn't expecting that the 'output' would be installable/runnable, and for that (install/run) step one would also need the GfW patches.

The confusing (for me) part is exactly where the '32-bit' choice shims itself into build/link/install/run chain, with (different) nuances at each step?

You also mentioned the c data type issue (which I'd also tripped over and had a local fix) but it didn't achieve the fix I expected (maybe because of the lack of tboegi's series..). I think I had fixed the zlib code and the crc32 library code, both of which have 32bit limits (IIUC).

@tboegi
Copy link

tboegi commented Apr 2, 2019

@PhilipOakley
Copy link

@dscho Sorry to be a bother, but I can't appear to get the "Rebasing Git for Windows" to work for me for the case where I have added my extra patches (size_t3) on top of @tboegi branch from yesterday (which I'm sure is on top of upstream git).

I'm trying to go through the GfW rebase but only got the single staring rebase 'merge commit', without anything else - I was expecting a forest of stuff.
I used the command ../build-extra/./shears.sh --merging --onto size_t3_pjo1 $BASE (from my gfw-master branch, up-to-date with origin/master) where 'size_t3_pjo1' is the tag of my local 'release' size_t3 branch.

The todo list looked like

exec "/usr/src/build-extra/shears.sh" start_merging_rebase
label onto

# Rebase b0096eaf8f..dc2ae9a382 onto dabdcc81ff (1 command)

i.e. too short..

I'm at a bit of a loss as to what I've done wrong. Any clues, suggestions or pointers would be of great help.

@PhilipOakley
Copy link

It looks like the current calculation of $BASE doesn't pick up the right location because there's a local trial rebase in the history.

phili@Philip-Win10 MINGW64 /usr/src/git (gfw-master)
$ BASE="$(git rev-parse ":/Start the merging-rebase")"
$ echo $BASE
b0096eaf8f01ac11c64166b3c11c62ca6a2268dd

$ git branch -a --contains $BASE
  remotes/origin/shears/pu
$ git describe --all --contains $BASE
remotes/origin/shears/pu~36

That commit is "Start the merging-rebase to upstream/pu" (2019-04-02), so I'll look for the right one

@PhilipOakley
Copy link

I've updated the wiki Rebasing Git for Windows. Use git rev-parse HEAD^{"/Start the merging-rebase}" (when on your master)

Dscho has noted footnote that he now also keeps a recent rebase in the /shears/ namespace. so benefit all-round.

@dscho
Copy link
Member

dscho commented Jun 4, 2019

@PhilipOakley sorry to be so quiet, I was heads-down in the conversion of git add -i to a built-in, and then simply forgot about these questions.

To answer some of them: yes, you are right, the shears.sh script is very much tied to my own workflow. I bet that you would be happier in most cases by using a git rebase -i directly (in rare cases, maybe, git rebase -ir, i.e. recreating the merge commits).

Anyway, for lurkers: @PhilipOakley opened #2179 and I just updated it to the current master, so we can take it from there.

@dscho
Copy link
Member

dscho commented Jun 4, 2019

I've updated the wiki Rebasing Git for Windows. Use git rev-parse HEAD^{"/Start the merging-rebase}" (when on your master)

Indeed. The problem with :{/^"Start the merging-rebase"} is that it looks for the first matching commit that is reachable from any ref, not just from HEAD.

I updated https://github.com/git-for-windows/git/wiki/Rebasing-Git-for-Windows in a couple of ways, hopefully you find it helpful:

  • There is no need to determine the base manually, there is the magic merging-rebase placeholder that is interpolated by the shears.sh script (because it is such a common need).
  • I also tried to explain a bit about the git range-diff command and how it can be used to compare pre-rebase to post-rebase commits in an efficient way.

@dscho
Copy link
Member

dscho commented Oct 15, 2021

Closing this as stale.

@dscho dscho closed this as completed Oct 15, 2021
PhilipOakley added a commit to PhilipOakley/git that referenced this issue Oct 21, 2021
Test whether the Git CI system allows, or fails, when LLP64 systems
need variable type coercion from size_t back to unsigned long.

All the *nix systems should pass, but compile checks for LLP64 systems
may fail. This is a crucial information spike for Git files > 4Gb,
i.e. Issues: git-lfs git-for-windows#2434, GfW git-for-windows#2179, git-for-windows#1848, git-for-windows#3306.

Signed-off-by: Philip Oakley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
@dscho @ribalda @PhilipOakley @tboegi @raggot and others