Bug 1668033

Summary: rustc 1.32.0 gets SIGSEGV when compiling with LTO
Product: [Fedora] Fedora Reporter: Josh Stone <jistone>
Component: llvmAssignee: Tom Stellard <tstellar>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: davejohansen, dmalcolm, igor.raits, jakub, jbuchert, jeremy.linton, jistone, rust-sig, scottt.tw, sguelton, siddharth.kde, TicoTimo, tstellar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: llvm-7.0.1-2.fc30 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1668072 1668075 (view as bug list) Environment:
Last Closed: 2019-01-21 23:53:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1668072, 1668075, 1699374    

Description Josh Stone 2019-01-21 18:11:36 UTC
Koschei is reporting build failures in several packages, and the common thread is that they're all applications building with "-C lto", via "lto = true" in Config.toml.

Here's what coredumpctl captured from one crash:

Stack trace of thread 18508:                                                                                                                               
#0  0x00007f2398ae02e3 _ZN4llvm9DwarfUnit16constructTypeDIEERNS_3DIEEPKNS_15DICompositeTypeE (libLLVM-7.so)                                                
#1  0x00007f2398ae055c _ZN4llvm9DwarfUnit18getOrCreateTypeDIEEPKNS_6MDNodeE (libLLVM-7.so)                                                                 
#2  0x00007f2398ae0588 _ZN4llvm9DwarfUnit7addTypeERNS_3DIEEPKNS_6DITypeENS_5dwarf9AttributeE (libLLVM-7.so)                                                
#3  0x00007f2398ae21c4 _ZN4llvm9DwarfUnit18constructMemberDIEERNS_3DIEEPKNS_13DIDerivedTypeE (libLLVM-7.so)                                                
#4  0x00007f2398ae0094 _ZN4llvm9DwarfUnit16constructTypeDIEERNS_3DIEEPKNS_15DICompositeTypeE (libLLVM-7.so)                                                
#5  0x00007f2398ae055c _ZN4llvm9DwarfUnit18getOrCreateTypeDIEEPKNS_6MDNodeE (libLLVM-7.so)                                                                 
#6  0x00007f2398ae0588 _ZN4llvm9DwarfUnit7addTypeERNS_3DIEEPKNS_6DITypeENS_5dwarf9AttributeE (libLLVM-7.so)                                                
#7  0x00007f2398ae29d5 _ZN4llvm9DwarfUnit16constructTypeDIEERNS_3DIEEPKNS_13DIDerivedTypeE (libLLVM-7.so)                                                  
#8  0x00007f2398ae0549 _ZN4llvm9DwarfUnit18getOrCreateTypeDIEEPKNS_6MDNodeE (libLLVM-7.so)                                                                 
#9  0x00007f2398ae0588 _ZN4llvm9DwarfUnit7addTypeERNS_3DIEEPKNS_6DITypeENS_5dwarf9AttributeE (libLLVM-7.so)                                                
#10 0x00007f2398ae0904 _ZN4llvm9DwarfUnit33constructTemplateTypeParameterDIEERNS_3DIEEPKNS_23DITemplateTypeParameterE (libLLVM-7.so)                       
#11 0x00007f2398ae09ab _ZN4llvm9DwarfUnit17addTemplateParamsERNS_3DIEENS_24MDTupleTypedArrayWrapperINS_6DINodeEEE (libLLVM-7.so)                           
#12 0x00007f2398adff36 _ZN4llvm9DwarfUnit16constructTypeDIEERNS_3DIEEPKNS_15DICompositeTypeE (libLLVM-7.so)                                                
#13 0x00007f2398ae055c _ZN4llvm9DwarfUnit18getOrCreateTypeDIEEPKNS_6MDNodeE (libLLVM-7.so)                                                                 
#14 0x00007f2398ae0588 _ZN4llvm9DwarfUnit7addTypeERNS_3DIEEPKNS_6DITypeENS_5dwarf9AttributeE (libLLVM-7.so)                                                
#15 0x00007f2398ae21c4 _ZN4llvm9DwarfUnit18constructMemberDIEERNS_3DIEEPKNS_13DIDerivedTypeE (libLLVM-7.so)                                                
#16 0x00007f2398ae0094 _ZN4llvm9DwarfUnit16constructTypeDIEERNS_3DIEEPKNS_15DICompositeTypeE (libLLVM-7.so)                                                
#17 0x00007f2398ae055c _ZN4llvm9DwarfUnit18getOrCreateTypeDIEEPKNS_6MDNodeE (libLLVM-7.so)                                                                 
#18 0x00007f2398ae0588 _ZN4llvm9DwarfUnit7addTypeERNS_3DIEEPKNS_6DITypeENS_5dwarf9AttributeE (libLLVM-7.so)                                                
#19 0x00007f2398aba11e _ZN4llvm16DwarfCompileUnit28getOrCreateGlobalVariableDIEEPKNS_16DIGlobalVariableENS_8ArrayRefINS0_10GlobalExprEEE (libLLVM-7.so)    
#20 0x00007f2398ad24a8 _ZN4llvm10DwarfDebug11beginModuleEv (libLLVM-7.so)                                                                                  
#21 0x00007f2398a9b828 _ZN4llvm10AsmPrinter16doInitializationERNS_6ModuleE (libLLVM-7.so)                                                                  
#22 0x00007f23984e2386 _ZN4llvm13FPPassManager16doInitializationERNS_6ModuleE (libLLVM-7.so)
#23 0x00007f23984ed42e _ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE (libLLVM-7.so)
#24 0x00007f239b3bed2f LLVMRustWriteOutputFile (librustc_codegen_llvm-llvm.so)
#25 0x00007f239b2f003c _ZN18rustc_codegen_llvm4back5write17write_output_file17h8640b21091d225e7E (librustc_codegen_llvm-llvm.so)                           
#26 0x00007f239b2f39bd _ZN18rustc_codegen_llvm4back5write7codegen28_$u7b$$u7b$closure$u7d$$u7d$17h1a7e36b365c885d3E (librustc_codegen_llvm-llvm.so)        
#27 0x00007f239b2f2cdf _ZN18rustc_codegen_llvm4back5write7codegen17h3fb5e75aa61c6649E (librustc_codegen_llvm-llvm.so)                                      
#28 0x00007f239b2b232a _ZN17rustc_codegen_ssa4back5write17execute_work_item17h8478d07a81e84411E (librustc_codegen_llvm-llvm.so)                            
#29 0x00007f239b385ea2 _ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h1a45e9838c6e7a5eE (librustc_codegen_llvm-llvm.so)                     
#30 0x00007f239b27d0e9 _ZN3std9panicking3try7do_call17h11ffb085c1ba8f61E.llvm.13712037126756632532 (librustc_codegen_llvm-llvm.so)                         
#31 0x00007f239def30ea __rust_maybe_catch_panic (libstd-3572d7be0ebc7029.so)
#32 0x00007f239b2834b8 _ZN50_$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$8call_box17h6199afcf2d39ee01E (librustc_codegen_llvm-llvm.so)                
#33 0x00007f239dee3dfe _ZN3std10sys_common6thread12start_thread17hd08795d0743f8679E (libstd-3572d7be0ebc7029.so)                                           
#34 0x00007f239deb7366 _ZN3std3sys4unix6thread6Thread3new12thread_start17h075b38fc29fe00c4E (libstd-3572d7be0ebc7029.so)                                   
#35 0x00007f239b6b058e start_thread (libpthread.so.0)
#36 0x00007f239dd9b6a3 __clone (libc.so.6)

It only happens with LLVM7 -- F28 with LLVM6 and EPEL7 with LLVM5 are fine. Upstream rustc using a snapshot of LLVM trunk (pre-8) is also fine.

Comment 1 Josh Stone 2019-01-21 18:16:38 UTC
Rust 1.31.1 was fine, but it fails on 1.32.0 through to master (though strangely only if I set --release-channel stable). I already bisected the rust side to commit 71ce4c3007b9, part of Rust #54004. That new debug change is only enabled for LLVM7+, so it makes sense that older LLVMs are unaffected.

https://github.com/rust-lang/rust/pull/54004

I will now try to reproduce with pre-release LLVM8, and if that's working I'll see if I can bisect a possible fix from that side.

Comment 2 Josh Stone 2019-01-21 18:59:42 UTC
I confirmed that LLVM r342725 solves it, as mentioned here:
https://github.com/rust-lang/rust/issues/57762#issuecomment-456155466

Comment 3 Josh Stone 2019-01-21 23:53:51 UTC
Should be fixed by llvm-7.0.1-2.fc30 on rawhide, and I've added llvm-7.0.1-2.fc29 to my bodhi update for rust-1.32.0-1.fc29.
https://bodhi.fedoraproject.org/updates/FEDORA-2019-c790d75439

Comment 4 Josh Stone 2019-01-30 00:08:01 UTC
*** Bug 1670502 has been marked as a duplicate of this bug. ***