coreutils: Disable sparse copy on macOS#11960
coreutils: Disable sparse copy on macOS#11960httpstorm wants to merge 1 commit intoopenwrt:masterfrom
Conversation
In addition to version update, this commit applies a fixup to allow building on MacOS involving renaming: [gt_TYPE_WINT_T] --> [gt_TYPE_WINT_T_GNUTLS] suggested by zhanhb. Build system: x86_64 Build-tested: bcm2711/RPi4B Signed-off-by: John Audia <[email protected]>
|
Overview Details
Note I'm curious what conditions trigger this? |
Kconfig docs say: > The default value deliberately defaults to 'n' in order to avoid > bloating the build. Apply this rule everywhere, to avoid more cloning of bad examples Signed-off-by: Tony Butler <[email protected]>
|
@httpstorm i would accept this patch as a workaround BUT we really need a way to tell coreutils that there is this kind of problem... To me it really seems a bug in apple virtual disk... a bug in compacting the virtual disk and something is dropped for sparse files? A good idea would be create a repro env so coreutils guys can quickly repro this. (a good argument to gain some traction may be that we recently switched to new version on openwrt and this started to get broken and is caused by the new sparse feature) |
Due to a bug in macOS, sparse copies are corrupted on virtual disks formatted with APFS. HFS is not affected. Affected are coreutils install, and gcp when compiled with SEEK_HOLE, as well as macOS Finder. While reading the entire file returns valid data, scanning for allocated segments may return holes where valid data is present. In this case a sparse copy does not contain these segments and return zeroes instead. Once the virtual disk is dismounted and then mounted again, a sparse copy produces correct results. This breaks OpenWRT build on macOS. Details: openwrt/openwrt#11960 Signed-off-by: Georgi Valkov <[email protected]>
|
@Ansuel I also created a pull request, but it seems they don't like using Github. Creating a repro environment steps to reproduce Create a sparse disk image with APFS
clone and build coreutils cd /Volumes/test
# patched with sparse support disabled on macOS
git clone https://github.com/httpstorm/coreutils.git
mv coreutils coreutils-no-sparse
cd coreutils-no-sparse
git checkout macos_disable-sparse-copy
git submodule foreach git pull origin master
./bootstrap
./configure
make -j 16
cd ..
# original code
git clone https://github.com/coreutils/coreutils.git
cd coreutils
git submodule foreach git pull origin master
./bootstrap
./configure
make -j 16download OpenWRT and build gcc cd /Volumes/test
git clone https://github.com/openwrt/openwrt.git
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
make defconfig
make menuconfig
# Target System (Marvell EBU Armada)
# Target Profile (Linksys WRT3200ACM)
# Save, Exit
make tools/compile -j 16
make toolchain/gcc/initial/compile -j 16proof of concept cd /Volumes/test/openwrt
cd build_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-12.2.0_musl_eabi/gcc-12.2.0-initial/gcc
/Volumes/test/coreutils/src/cp cc1 cc1-ori
./cc1-ori --help
-bash: ./cc1-ori: cannot execute binary file: Exec format error
/Volumes/test/coreutils-no-sparse/src/cp cc1 cc1-fix
./cc1-fix --help
# works correctly
sha1sum cc1
# fcf5d9458f54d5588efc5a76a89388925ca04eda cc1
sha1sum cc1-fix
# fcf5d9458f54d5588efc5a76a89388925ca04eda cc1-fix
sha1sum cc1-ori
# 7b447132f56f3b549ef62a4780945e82d26f7d2c cc1-ori |
|
Good news, I got a replay on the We'll try to test for a better solution and fall-back to accepting the patch. |
|
@httpstorm nice! then lets wait |
|
We implemented a solution: for copies on the same filesystem, edit: This link explains why sparse copies were corrupted. |
|
@httpstorm is the patch got merged in coreutils repo? If it's the case then lets just backport the fix to the current release... It's totally ok to backport merged patch... not ok to add workaround without approval from the related repo. |
|
@Ansuel No, it's not merged yet, and I expect two patches: the one in this pull request, and another to enable CoW. But let's wait until they confirm everything is merged. I posted earlier to keep you updated. I just tested the suggested patch and confirmed everything is ok. You can find our conversation and patch details on the mailing list. Link in a previous comment. |
|
I found the underlaying issue: one way of creating sparse files is to map a file to memory view using I am still working with the coreutil team. We wanted to make sure we know the reason for the issue, and that compliance is maintained. |
|
(me being very picky) please wrap the link with the commit tag Link: has anyone looked into whether coreutils can be configured this way instead of patching? |
@mpratt14 I'm still working with the They recently committed a few patches to Savannah, that address the issue, however that broke some of the tests. They added more patches yesterday but now the tests hang, so I just sent them a new report. Hopefully they will address it soon. The fix is way more sophisticated than my PR, so I will close it when everything settles, and we'll update to a new version of |
Due to a bug in macOS, sparse copies are corrupted on virtual disks formatted with APFS. HFS is not affected. Affected are coreutils install, and gcp when compiled with SEEK_HOLE, as well as macOS Finder. While reading the entire file returns valid data, scanning for allocated segments may return holes where valid data is present. In this case a sparse copy does not contain these segments and return zeroes instead. Once the virtual disk is dismounted and then mounted again, a sparse copy produces correct results. This breaks OpenWRT build on macOS. Steps to reproduce: https://httpstorm.com/share/.openwrt/test/2023-02-06_coreutils-9.1/ Coreutils bug report and discussion https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61386 Signed-off-by: Georgi Valkov <[email protected]>
6779b5a to
c1bf131
Compare
|
|
|
@httpstorm news with this? |
|
@Ansuel
|
|
@httpstorm btw if we notice problem with 9.2 backporting the patch is a way (just for reference) |
|
Coreutils 9.2 is now released |
|
@pixelb Thank you very much for all your work, Pádraig! I will send you the test results later. So far everything works well. I also installed and tested |
|
@pixelb @Ansuel Once we update I created a draft PR to update to |
This resolves an error when building toolchain/musl on macOS due to improper hole-detection caused by a bug in macOS/APFS: openwrt#11960 As long as we don't reconfigure, 001-m4.patch is not needed. If we keep it, it will force reconfigure the project, since m4 files are changed. This works, but may not be optimal, because the build should use files from coreutils/m4, but OpenWRT uses legacy files from staging_dir/host/share/aclocal. openwrt#12233 (comment) Coreutils bug report and discussion https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61386 Signed-off-by: Georgi Valkov <[email protected]>
This resolves an error when building toolchain/musl on macOS due to improper hole-detection caused by a bug in macOS/APFS: openwrt#11960 As long as we don't reconfigure, 001-m4.patch is not needed. If we keep it, it will force reconfigure the project, since m4 files are changed. This works, but may not be optimal, because the build should use files from coreutils/m4, but OpenWRT uses legacy files from staging_dir/host/share/aclocal. openwrt#12233 (comment) Coreutils bug report and discussion https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61386 backport a couple of upstream patches as requested by mpratt14 date: diagnose -f read errors copy: fix --reflink=auto to fallback in more cases Signed-off-by: Georgi Valkov <[email protected]>
This resolves an error when building toolchain/musl on macOS due to improper hole-detection caused by a bug in macOS/APFS: openwrt#11960 As long as we don't reconfigure, 001-m4.patch is not needed. If we keep it, it will force reconfigure the project, since m4 files are changed. This works, but may not be optimal, because the build should use files from coreutils/m4, but OpenWRT uses legacy files from staging_dir/host/share/aclocal. openwrt#12233 (comment) Coreutils bug report and discussion https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61386 backport a couple of upstream patches as requested by mpratt14 date: diagnose -f read errors copy: fix --reflink=auto to fallback in more cases Signed-off-by: Georgi Valkov <[email protected]>
|
This was fixed by updating coreutils to version 9.2, see #12233 |
The bug appears to be resolved: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61386 See also here: openwrt/openwrt#11960 (comment) And here: openwrt/openwrt#12233
@hauke @graysky2 @neheb @Ansuel @nbd168
Fix build errors in
toolchain/muslandtoolchain/kernel-headersintroduced in c560822 tools/coreutils: update to 9.1Due to a bug in macOS, sparse copies are corrupted on virtual disks formatted with APFS. HFS is not affected.
Affected are coreutils
install, andgcpwhen compiled withSEEK_HOLE, as well as macOS Finder.When the compiler is installed, a corrupted copy is created, which cannot be executed, so the build fails.
While reading the entire file returns valid data, scanning for allocated segments may return holes where valid data is present. In this case a sparse copy does not contain these segments and return zeroes instead. Once the virtual disk is dismounted and then mounted again, a sparse copy produces correct results.
I tried contacting Apple and the coreutils team in 2021 to no avail. What would be the best way to make them aware?
Tested on macOS 12.6.3 x64, targets WRT3200ACM, x64
Steps to reproduce, config and build log: https://httpstorm.com/share/.openwrt/test/2023-02-06_coreutils-9.1/
Build log