Issue 139802
Summary Crash when using --lto-whole-program-visibility
Labels new issue
Assignees
Reporter bgemmill
    I'm using clang 20 from the ubuntu ppa [here](https://apt.llvm.org/).

When compiling my code with `-flto=thin -fwhole-program-vtables -Wl,--lto-whole-program-visibility` to devirtualize calls in my code, I get a segfault.

The segfault only seems to occur when all three options are enabled, using only `-flto=thin -fwhole-program-vtables` does not cause crashes. According to godbolt, it's also less effective at devirtualization.

Please let me know if there's anything else I can provide.




```
$ clang --version
Ubuntu clang version 20.1.5 (++20250430014901+ebfae55af454-1~exp1~20250430014920.111)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-20/bi

$ ld --version
Ubuntu LLD 20.1.5 (compatible with GNU linkers
```

```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
1.      Running pass "lowertypetests" on module "ld-temp.o"
 #0 0x00007fe688266c7f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-20/bin/../lib/libLLVM.so.20.1+0x102bc7f)
 #1 0x00007fe688264989 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-20/bin/../lib/libLLVM.so.20.1+0x1029989)
 #2 0x00007fe688267390 (/usr/lib/llvm-20/bin/../lib/libLLVM.so.20.1+0x102c390)
 #3 0x00007fe686cd7330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #4 0x00007fe6895321f7 (/usr/lib/llvm-20/bin/../lib/libLLVM.so.20.1+0x22f71f7)
 #5 0x00007fe689528805 (/usr/lib/llvm-20/bin/../lib/libLLVM.so.20.1+0x22ed805)
 #6 0x00007fe6895245cf llvm::LowerTypeTestsPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/lib/llvm-20/bin/../lib/libLLVM.so.20.1+0x22e95cf)
 #7 0x00007fe68b92d726 (/usr/lib/llvm-20/bin/../lib/libLLVM.so.20.1+0x46f2726)
 #8 0x00007fe6883fe3e5 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/lib/llvm-20/bin/../lib/libLLVM.so.20.1+0x11c33e5)
 #9 0x00007fe689ab4683 llvm::lto::opt(llvm::lto::Config const&, llvm::TargetMachine*, unsigned int, llvm::Module&, bool, llvm::ModuleSummaryIndex*, llvm::ModuleSummaryIndex const*, std::vector<unsigned char, std::allocator<unsigned char>> const&) (/usr/lib/llvm-20/bin/../lib/libLLVM.so.20.1+0x2879683)
#10 0x00007fe689ab4e84 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-20/bin/../lib/libLLVM.so.20.1+0x2879e84)
#11 0x00007fe689aa42d9 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-20/bin/../lib/libLLVM.so.20.1+0x28692d9)
#12 0x00007fe689aa374d llvm::lto::LTO::run(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, llvm::FileCache) (/usr/lib/llvm-20/bin/../lib/libLLVM.so.20.1+0x286874d)
#13 0x000062d92d0d668d lld::elf::BitcodeCompiler::compile() (/usr/bin/ld+0x24468d)
#14 0x000062d92d063fd0 void lld::elf::LinkerDriver::compileBitcodeFiles<llvm::object::ELFType<(llvm::endianness)1, true>>(bool) (/usr/bin/ld+0x1d1fd0)
#15 0x000062d92d04a819 void lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::endianness)1, true>>(llvm::opt::InputArgList&) (/usr/bin/ld+0x1b8819)
#16 0x000062d92d035259 lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) (/usr/bin/ld+0x1a3259)
#17 0x000062d92d031f09 lld::elf::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/usr/bin/ld+0x19ff09)
#18 0x000062d92cf619d3 lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) (/usr/bin/ld+0xcf9d3)
#19 0x000062d92cf60c64 lld_main(int, char**, llvm::ToolContext const&) (/usr/bin/ld+0xcec64)
#20 0x000062d92cf612b3 main (/usr/bin/ld+0xcf2b3)
#21 0x00007fe686cbc1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#22 0x00007fe686cbc28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#23 0x000062d92cf60895 _start (/usr/bin/ld+0xce895)
c++: error: unable to execute command: Segmentation fault (core dumped)
c++: error: linker command failed due to signal (use -v to see invocation)
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to