Bug 1668072

Summary: rustc 1.32.0 gets SIGSEGV when compiling with LTO
Product: Red Hat Enterprise Linux 8 Reporter: Josh Stone <jistone>
Component: llvm-toolsetAssignee: serge_sans_paille <sguelton>
Status: CLOSED ERRATA QA Contact: Miloš Prchlík <mprchlik>
Severity: unspecified Docs Contact: Vladimír Slávik <vslavik>
Priority: unspecified    
Version: 8.0CC: bgollahe, mcermak, mnewsome, mprchlik, toneata
Target Milestone: rcKeywords: ZStream
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: 1668033
: 1699374 (view as bug list) Environment:
Last Closed: 2019-11-05 20:56:03 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: 1668033    
Bug Blocks: 1699374, 1701002    

Description Josh Stone 2019-01-21 20:36:50 UTC
+++ This bug was initially created as a clone of Bug #1668033 +++

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.

--- Additional comment from Josh Stone on 2019-01-21 10:16:38 PST ---

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.

--- Additional comment from Josh Stone on 2019-01-21 10:59:42 PST ---

I confirmed that LLVM r342725 solves it, as mentioned here:
https://github.com/rust-lang/rust/issues/57762#issuecomment-456155466

Comment 3 Oneata Mircea Teodor 2019-04-12 14:31:56 UTC
This bug has been copied as 8.0.0 z-stream  bug #1699374  and now must be
resolved in the current update release, set blocker flag.

Comment 4 serge_sans_paille 2019-05-15 12:10:10 UTC
tstellar, should we apply the patch to llvm-compat that still ships llvm-7.0.1?

Comment 5 Josh Stone 2019-05-15 15:10:39 UTC
Those patches are already present with a comment for rhbz#1699374.

Comment 6 serge_sans_paille 2019-05-16 10:57:37 UTC
josh: correct, the patch is actually already applied to llvm-compat through 0001-Ensure-that-variant-part-discriminator-is-read-by-Me.patch, and naturally present in llvm-8.0.0.

Comment 8 Miloš Prchlík 2019-08-27 09:11:06 UTC
Verified with llvm-toolset:rhel8:8010020190802085723:cdc1202b.

Comment 10 errata-xmlrpc 2019-11-05 20:56:03 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2019:3370