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

Installing LuaJIT sometimes fails with SHA256 mismatch #27

Closed
mpeterv opened this issue Jun 21, 2016 · 6 comments
Closed

Installing LuaJIT sometimes fails with SHA256 mismatch #27

mpeterv opened this issue Jun 21, 2016 · 6 comments

Comments

@mpeterv
Copy link
Owner

mpeterv commented Jun 21, 2016

For instance, when installing LuaJIT 2.0.4 this can happen:

Fetching LuaJIT from https://github.com/LuaJIT/LuaJIT/archive/v2.0.4.tar.gz
Verifying SHA256 checksum
Error: SHA256 checksum mismatch for /home/mpeterv/.cache/hererocks/LuaJIT-2.0.4.tar.gz
Expected: d2abdf16bd3556c41c0aaedad76b6c227ca667be8350111d037a4c54fd43abad
Observed: 324f191dcf771310be0fc6496f7282387be9cf8d38b105566226c6cb079e90eb

Happens with LuaJIT 2.1.0-beta2, too. SHA256 for other downloads seemingly don't mismatch. Observed invalid checksums are the same every time.

Comparing normal and invalid files (at least for LuaJIT 2.0.4) shows that the invalid one is almost correct but has extra 7 bytes prepended and appended to it. Prefix is d0a4f\r\n and suffix is \r\n0\r\n\r\n.

The failures happen on Travis/Appveyor fairly often but I've only managed to reproduce it locally once.

@mpeterv
Copy link
Owner Author

mpeterv commented Jun 21, 2016

Reproduced locally for LuaJIT 2.1.0, again, get the expected file with prefix and suffix, prefix is e8119\r\n and suffix is the same, \r\n0\r\n\r\n. Reproduction done using urllib.urlretrieve, which is what hererocks calls.

@mpeterv
Copy link
Owner Author

mpeterv commented Jun 21, 2016

Calling urlretrieve in a loop shows that the first download for each url is broken, the following ones are OK. Perhaps either github or urlretrieve handle chunked encoding incorrectly?..

@mpeterv
Copy link
Owner Author

mpeterv commented Jun 21, 2016

Using curl --verbose, indeed, GitHub appears to use Transfer-Encoding: chunked, but only on the first request for each url, with a reset after some delay.

@mpeterv
Copy link
Owner Author

mpeterv commented Jun 21, 2016

Of course, the "prefix" is file length in hexadecimal, so the broken file is just full chunk encoded file. Not sure why GitHub decides to send the whole file in one chunk, or why urlretrieve can't handle it,

@mpeterv
Copy link
Owner Author

mpeterv commented Jun 21, 2016

OK, so urllib doesn't support chunked transfer (httplib has functions for working with it but they are not used), but urllib2 does, and so does urllib.request from Python 3.

@mpeterv mpeterv closed this as completed Jun 21, 2016
@mpeterv
Copy link
Owner Author

mpeterv commented Jun 21, 2016

Fixed in @a9b8ab9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant