Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 910438

Summary: app-arch/lbzip2: Sometimes produces corrupt archives when compiled with clang and vectorization with certain march values.
Product: Gentoo Linux Reporter: Violet Purcell <vimproved>
Component: Current packagesAssignee: Matt Turner <mattst88>
Status: UNCONFIRMED ---    
Severity: normal CC: ionen, lockalsash, sam, toolchain, vimproved
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=476682
https://github.com/llvm/llvm-project/issues/87189
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 408963, 915000    

Description Violet Purcell 2023-07-16 20:13:39 UTC
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"
Comment 1 Sv. Lockal 2024-02-15 08:23:21 UTC
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.
Comment 2 Sv. Lockal 2024-03-31 11:24:42 UTC
Reported to LLVM as https://github.com/llvm/llvm-project/issues/87189.

Workaround is:

  tc-is-clang && append-flags "-mno-avx512f"
Comment 3 Violet Purcell 2024-04-01 13:26:56 UTC
Thanks for the more detailed analysis.