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

[binarycaching] linux copy_file is restricted to 2GiB #21557

Closed
Osyotr opened this issue Nov 20, 2021 · 7 comments
Closed

[binarycaching] linux copy_file is restricted to 2GiB #21557

Osyotr opened this issue Nov 20, 2021 · 7 comments
Assignees
Labels
category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`) requires:tool-release An issue that has been fixed in the microsoft/vcpkg-tool repo and is waiting for a release thereof

Comments

@Osyotr
Copy link
Contributor

Osyotr commented Nov 20, 2021

Describe the bug
I'm building qt5-webkit for x64-linux-dynamic. The build is successful and vcpkg kindly creates binary cache for it. However, when I restore the library from cache, one file gets corrupted (truncated from 2.7gb to exactly 2gb, see screenshot). If I manually unpack the archive (e.g. unzip -qq /home/osyotr/.cache/vcpkg/archives/7b/7bc45507c4cc57f59860de97c1c38bdce12b35a07d5ecc3c8136b4ad44f6af75.zip -d/mnt/d/my_project/vcpkg_installed/x64-linux or just drag'n'drop from 7zip), the file doesn't get corrupted.
I suspect the real problem is not in unpacking, but in transferring files between packages/ dir and vcpkg_installed/ dir.
I also suspect that this is a regression because I was able to link against the library before updating ~2 months old vcpkg instance.
Maybe microsoft/vcpkg-tool#205? @BillyONeal

Environment

  • OS: WSL2 Debian

To Reproduce

  1. Install WSL2 on C:/ (this is default)
  2. Put vcpkg.json on D:/
  3. From inside WSL run ./vcpkg install qt5-webkit --overlay-ports=vcpkg_overlay_ports --overlay-triplets=vcpkg_overlay_triplets --debug
  4. After successful build remove ~/vcpkg/packages/ and vcpkg_installed folders.
  5. Repeat the command from 3.
  6. Compare sizes of vcpkg_installed/lib/libQt5WebKit.so.5.212.0
    I've attached overlay ports and triplets I used to build the library, as well as vcpkg.json and vcpkg-configuration.json.
    qt5-base overlay port and x64-linux triplets are probably not needed but I attached them anyway. (both contain rpath fixes but I think the issue can be reproduced with official x64-linux triplet).
    vcpkg_overlay_ports_triplets.zip

Failure logs
No errors reported.

Additional context
image

@BillyONeal
Copy link
Member

BillyONeal commented Nov 21, 2021

Oh dear, this is what I get for assuming the old code was correct.

As part of the indicated PR, I reused the existing code that called sendfile from rename_or_copy for the new copy_file, with the assumption that that had been in the product forever and thus had to be correct.

Well... https://man7.org/linux/man-pages/man2/sendfile.2.html#NOTES

image

@BillyONeal BillyONeal changed the title [binarycaching] corrupted files when restoring library from local cache [binarycaching] linux copy_file is restricted to 2GiB Nov 21, 2021
@BillyONeal BillyONeal self-assigned this Nov 21, 2021
@strega-nil
Copy link
Contributor

strega-nil commented Nov 21, 2021

Oh dear, this is what I get for assuming the old code was correct.
As part of the indicated PR, I reused the existing code that called sendfile from rename_or_copy for the new copy_file, with the assumption that that had been in the product forever and thus had to be correct.
Well... https://man7.org/linux/man-pages/man2/sendfile.2.html#NOTES

are you kidding me :'(

edit: oh, note this here:

The glibc sendfile() wrapper function transparently deals with the kernel differences [between sendfile() and sendfile64()].

@JackBoosY JackBoosY added the category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`) label Nov 23, 2021
@JackBoosY
Copy link
Contributor

The glibc sendfile() wrapper function transparently deals with the kernel differences [between sendfile() and sendfile64()].

So we should use sendfile64() in x64 arch, right?

@BillyONeal
Copy link
Member

edit: oh, note this here:

The glibc sendfile() wrapper function transparently deals with the kernel differences [between sendfile() and sendfile64()].

As far as I can see sendfile64 only changes the type and behavior of the offset member, it doesn't enable copying more than 2 GiB in a single call.

The glibc sendfile() wrapper function transparently deals with the kernel differences [between sendfile() and sendfile64()].

So we should use sendfile64() in x64 arch, right?

I don't think it's arch dependent.

@BillyONeal
Copy link
Member

I was not able to test with this example because GCC 9.3 emits a ton of "-Wno-redundant-move" errors which causes that overlayed qt build to fail, but I still think the PR I submitted in the tool repo should fix the issue if you want to try building it yourself.

@PhoebeHui PhoebeHui added the requires:tool-release An issue that has been fixed in the microsoft/vcpkg-tool repo and is waiting for a release thereof label Jan 10, 2022
@autoantwort
Copy link
Contributor

Would be fixed by #22629

@BillyONeal
Copy link
Member

Fixed by #22629

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`) requires:tool-release An issue that has been fixed in the microsoft/vcpkg-tool repo and is waiting for a release thereof
Projects
None yet
Development

No branches or pull requests

6 participants