You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ mkdir git-repo
$ cd git-repo/
$ git init .
Initialized empty Git repository in .../git-repo/.git/
$ dd if=/dev/zero of=test4G bs=4M count=1024
1024+0 records in
1024+0 records out
4294967296 bytes (4.3 GB, 4.0 GiB) copied, 2.5895 s, 1.7 GB/s
$ git add test4G
$ git commit -m hello
[master (root-commit) 636cdb5] hello
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 test4G
$ git ls-tree $(git log -1 --pretty="%T" HEAD)
100644 blob 451971a31ea5a207a10b391df2d5949910133565 test4G
$ git show 451971a31ea5a207a10b391df2d5949910133565 | wc -c
error: bad object header
fatal: packed object 451971a31ea5a207a10b391df2d5949910133565 (stored in .git/objects/pack/pack-43e2c696ce675c3ed09d82deeed262b870b6f27b.pack) is corrupt
0
What did you expect to occur after running these commands?
No errors when running git show $hash
What actually happened instead?
Errors
If the problem was occurring with a specific repository, can you provide the
URL to that repository to help us with testing?
No need.
Additional notes:
Getting to that folder with WSL's git (git version 2.17.1) works (as expected. It looks like the problem is only when reading the packfile, not when writing. The packfile is not corrupt):
$ git show 451971a31ea5a207a10b391df2d5949910133565 | wc -c
4294967296
This seems to be related to code like (in packfile.c):
intunpack_object_header(structpacked_git*p,
structpack_window**w_curs,
off_t*curpos,
unsigned long*sizep)
{
unsigned char*base;
unsigned longleft;
unsigned longused;
enumobject_typetype;
/* use_pack() assures us we have [base, base + 20) available * as a range that we can look at. (Its actually the hash * size that is assured.) With our object header encoding * the maximum deflated object size is 2^137, which is just * insane, so we know won't exceed what we have been given. */base=use_pack(p, w_curs, *curpos, &left);
used=unpack_object_header_buffer(base, left, &type, sizep);
if (!used) {
type=OBJ_BAD;
} else*curpos+=used;
returntype;
}
curpos is off_t, which should be ok. But used is only an unsigned long, which is 32-bit on Windows (https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models ).
Changing left and used to be off_t (and then changing all callees) should fix this. How ok is it to create a test which generates a 4GiB file when being run?
I can try to fix this if I manage to get a build of git working on Windows. Should I then file a patch to this project or to the main git project? (Other platforms might have this problem, but I'm not aware of any. Still: It's probably more correct to use off_t in this code).
Thank you,
Filipe
The text was updated successfully, but these errors were encountered:
Unfortunately, it looks like git is assuming unsigned long is an acceptable type for offsets into packs, etc. Changing the type can involve changing many more functions than expected. I'll try and create a localized change (which would fix this bug but potentially leave a few unfixed).
yes that is a known and current limitation in git. I'm planning to get that fixed at some point, but I don't have an ETA. If you want to help and get that done earlier, feel free to contact me via my email @PhilipOakley linked above.
My current WIP and not-yet-working branch is at gitgitgadget#115.
Setup
defaults?
to the issue you're seeing?
Nope.
Details
bash
Minimal, Complete, and Verifiable example
this will help us understand the issue.
No errors when running
git show $hash
Errors
URL to that repository to help us with testing?
No need.
Getting to that folder with WSL's git (
git version 2.17.1
) works (as expected. It looks like the problem is only when reading the packfile, not when writing. The packfile is not corrupt):This seems to be related to code like (in
packfile.c
):curpos
isoff_t
, which should be ok. Butused
is only anunsigned long
, which is 32-bit on Windows (https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models ).Changing
left
andused
to beoff_t
(and then changing all callees) should fix this. How ok is it to create a test which generates a 4GiB file when being run?I can try to fix this if I manage to get a build of git working on Windows. Should I then file a patch to this project or to the main git project? (Other platforms might have this problem, but I'm not aware of any. Still: It's probably more correct to use
off_t
in this code).Thank you,
Filipe
The text was updated successfully, but these errors were encountered: