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

AMD64 segfault during LTO building linux-6.7.0 with clang-17.0.6 #1984

Closed
srcshelton opened this issue Jan 22, 2024 · 2 comments
Closed

AMD64 segfault during LTO building linux-6.7.0 with clang-17.0.6 #1984

srcshelton opened this issue Jan 22, 2024 · 2 comments
Labels
Changed defaults The compiler/linker/etc. has been patched to implicitly change a default value

Comments

@srcshelton
Copy link

(From https://github.com/llvm/llvm-project/issues/78732…)

Stack dump:
0.      Program arguments: ld.lld -m elf_x86_64 -mllvm -import-instr-limit=5 -z noexecstack -r -o arch/x86/crypto/ghash-clmulni-intel.o @arch/x86/crypto/ghash-clmulni-intel.mod
1.      Running pass 'Function Pass Manager' on module 'ld-temp.o'.
2.      Running pass 'Prologue/Epilogue Insertion & Frame Finalization' on function '@ghash_async_init'
 #0 0x00007f7ecffa4e9e llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm/17/bin/../lib64/libLLVM-17.so+0x9a4e9e)
 #1 0x00007f7ecffa2c44 llvm::sys::RunSignalHandlers() (/usr/lib/llvm/17/bin/../lib64/libLLVM-17.so+0x9a2c44)
 #2 0x00007f7ecffa2da6 (/usr/lib/llvm/17/bin/../lib64/libLLVM-17.so+0x9a2da6)
 #3 0x00007f7ecf05fb70 (/lib64/libc.so.6+0x38b70)
 #4 0x00007f7ed04c2301 (/usr/lib/llvm/17/bin/../lib64/libLLVM-17.so+0xec2301)
 #5 0x00007f7ed04c91a9 (/usr/lib/llvm/17/bin/../lib64/libLLVM-17.so+0xec91a9)
 #6 0x00007f7ed039cb5d llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/usr/lib/llvm/17/bin/../lib64/libLLVM-17.so+0xd9cb5d)
 #7 0x00007f7ed00ecc49 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib/llvm/17/bin/../lib64/libLLVM-17.so+0xaecc49)
 #8 0x00007f7ed00eced3 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/lib/llvm/17/bin/../lib64/libLLVM-17.so+0xaeced3)
 #9 0x00007f7ed00ed557 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/llvm/17/bin/../lib64/libLLVM-17.so+0xaed557)
#10 0x00007f7ed180d474 (/usr/lib/llvm/17/bin/../lib64/libLLVM-17.so+0x220d474)
#11 0x00007f7ed180dbaa llvm::lto::backend(llvm::lto::Config const&, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&) (/usr/lib/llvm/17/bin/../lib64/libLLVM-17.so+0x220dbaa)
#12 0x00007f7ed1803fc7 llvm::lto::LTO::runRegularLTO(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>) (/usr/lib/llvm/17/bin/../lib64/libLLVM-17.so+0x2203fc7)
#13 0x00007f7ed180443b llvm::lto::LTO::run(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, std::function<llvm::Expected<std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>> (unsigned int, llvm::StringRef, llvm::Twine const&)>) (/usr/lib/llvm/17/bin/../lib64/libLLVM-17.so+0x220443b)
#14 0x00007f7ed395d6d6 lld::elf::BitcodeCompiler::compile() (/usr/lib/llvm/17/bin/../lib64/liblldELF.so.17+0x15d6d6)
#15 0x00007f7ed38e01f7 void lld::elf::LinkerDriver::compileBitcodeFiles<llvm::object::ELFType<(llvm::support::endianness)1, true>>(bool) (/usr/lib/llvm/17/bin/../lib64/liblldELF.so.17+0xe01f7)
#16 0x00007f7ed38e8ae8 lld::elf::LinkerDriver::link(llvm::opt::InputArgList&) (/usr/lib/llvm/17/bin/../lib64/liblldELF.so.17+0xe8ae8)
#17 0x00007f7ed38eb3e0 lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) (/usr/lib/llvm/17/bin/../lib64/liblldELF.so.17+0xeb3e0)
#18 0x00007f7ed38ecddc lld::elf::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/usr/lib/llvm/17/bin/../lib64/liblldELF.so.17+0xecddc)
#19 0x00007f7ed3ae10ad lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) (/usr/lib/llvm/17/bin/../lib64/liblldCommon.so.17+0x100ad)
#20 0x000055ee43ce6d4c lld_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm/17/bin/ld.lld+0x3d4c)
#21 0x000055ee43ce6501 main (/usr/lib/llvm/17/bin/ld.lld+0x3501)
#22 0x00007f7ecf04ad77 (/lib64/libc.so.6+0x23d77)
#23 0x00007f7ecf04ae35 __libc_start_main (/lib64/libc.so.6+0x23e35)
#24 0x000055ee43ce6531 _start (/usr/lib/llvm/17/bin/ld.lld+0x3531)
Segmentation fault
make[6]: *** [/usr/src/linux-6.7.0/scripts/Makefile.build:438: arch/x86/crypto/ghash-clmulni-intel.o] Error 139
make[5]: *** [/usr/src/linux-6.7.0/scripts/Makefile.build:480: arch/x86/crypto] Error 2
make[4]: *** [/usr/src/linux-6.7.0/scripts/Makefile.build:480: arch/x86] Error 2
make[3]: *** [/usr/src/linux-6.7.0/Makefile:1911: .] Error 2
make[2]: *** [/usr/src/linux-6.7.0/Makefile:350: __build_one_by_one] Error 2
make[1]: *** [/usr/src/linux-6.7.0/Makefile:234: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/build'

If the kernel is reconfigured with this module disabled then there is a different crash in KVM, and if that is disabled then another module breaks. I stopped trying to dig any deeper at this point.

FWIW, on the same host building linux-6.6.9 with clang-16.0.6 and the same configuration worked as expected.

# /usr/lib/llvm/17/bin/clang --version
clang version 17.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/17/bin
Configuration file: /etc/clang/x86_64-pc-linux-gnu-clang.cfg

Configuration:

--rtlib=compiler-rt
--unwindlib=libunwind
--stdlib=libc++
-fuse-ld=lld
-Wl,-z,relro
--gcc-install-dir="/usr/lib/gcc/x86_64-pc-linux-gnu/13"
-fstack-clash-protection
-fstack-protector-strong
-fPIE
@nathanchance
Copy link
Member

This seems like the same crash that was reported in a comment by vtta on LLVM issue 72026, which should be fixed on main by llvm/llvm-project@f800c1f, as I note in my comment on that thread. Consider testing with main to confirm if you are able to.

@srcshelton
Copy link
Author

Perfect - applying https://github.com/llvm/llvm-project/commit/f800c1f3b207e7bcdc8b4c7192928d9a078242a0.patch and rebuilding llvm/clang/lld (all may not be necessary, but I wanted to be thorough) and then rebuilding the kernel has succeeded - many thanks for the super-fast response 😊

@nathanchance nathanchance added [BUG] llvm A bug that should be fixed in upstream LLVM [FIXED][LLVM] 18 This bug was fixed in LLVM 18.0 labels Jan 22, 2024
@nickdesaulniers nickdesaulniers added Changed defaults The compiler/linker/etc. has been patched to implicitly change a default value and removed [BUG] llvm A bug that should be fixed in upstream LLVM [FIXED][LLVM] 18 This bug was fixed in LLVM 18.0 labels Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changed defaults The compiler/linker/etc. has been patched to implicitly change a default value
Projects
None yet
Development

No branches or pull requests

3 participants