This is a really odd and specific bug that only happens under specific circumstances (most likely caused by UB), but it is reproducable. Reproducible: Always Steps to Reproduce: 1. Compile app-arch/lbzip2 with clang and CFLAGS="-march=skylake -O1 -fvectorize" 2. Copy an environment.bz2 file from /var/db/pkg (specifically reproduced using /var/db/pkg/dev-python/setuptools-68.0.0-r1/environment.bz2) 3. bunzip2 environment.bz2 && lbzip2 -9 environment && bunzip2 environment.bz2 4. You should get a Data integrity error. This bug only happens with clang, and can be reproduced using either of the following CFLAGS: CFLAGS="-march=skylake -O1 -fvectorize" CFLAGS="-mavx512f -O1 -fvectorize"
I had the same issue with `clang -flto=thin -O2 -march=native` system (znver4). Got a lot of broken environment.bz2 files. Maybe this is related to https://phabricator.wikimedia.org/T208647, but I just want to confirm that it is unsafe to use lbzip2 as bzip2 alternative in such conditions.
Reported to LLVM as https://github.com/llvm/llvm-project/issues/87189. Workaround is: tc-is-clang && append-flags "-mno-avx512f"
Thanks for the more detailed analysis.