Bug 2226564 - llc optional: Assertion 'this->_M_is_engaged()' failed.
Summary: llc optional: Assertion 'this->_M_is_engaged()' failed.
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: llvm
Version: 39
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Tom Stellard
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-07-26 00:34 UTC by Josh Stone
Modified: 2023-08-22 21:35 UTC (History)
12 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: ---
Embargoed:


Attachments (Terms of Use)
reduced.bc (43.20 KB, application/octet-stream)
2023-07-26 00:35 UTC, Josh Stone
no flags Details
original reproducer (3.28 MB, application/octet-stream)
2023-07-27 19:40 UTC, Josh Stone
no flags Details
original no-opt reproducer (2.03 MB, application/octet-stream)
2023-07-28 19:55 UTC, Josh Stone
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Github llvm llvm-project issues 64149 0 None open Assertion failure: "conflicting locations for variable" 2023-08-22 21:35:03 UTC
Github rust-lang rust issues 115113 0 None open ScalarReplacementOfAggregates causes rustc to emit invalid LLVM debuginfo (and sometimes rustc segfaults) 2023-08-22 21:35:03 UTC

Description Josh Stone 2023-07-26 00:34:48 UTC
While building a nightly version of the Rust toolchain, rustc->LLVM tripped an assertion in libstdc++'s optional header. I used "rustc -Csave-temps" to capture the last output before the crash, and applied llvm-reduce for a smaller test case, which I will attach.

Reproducible: Always

Steps to Reproduce:
1. llc reduced.bc

Actual Results:  
# llc reduced.bc
/usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/optional:477: _Tp &std::_Optional_base_impl<llvm::DIExpression::FragmentInfo, std::_Optional_base<llvm::DIExpression::FragmentInfo, true, true>>::_M_get() [_Tp = llvm::DIExpression::FragmentInfo, _Dp = std::_Optional_base<llvm::DIExpression::FragmentInfo, true, true>]: Assertion 'this->_M_is_engaged()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: llc reduced.bc
1.      Running pass 'Function Pass Manager' on module 'reduced.bc'.
2.      Running pass 'X86 Assembly Printer' on function '@_RINvYNtNtNtNtCsgBM6TfnZ7YU_5cargo4util6config2de12DeserializerNtNtCs8ELY4rCNAV8_5serde2de12Deserializer21___deserialize_contentNtNtNtNtB12_9___private2de7content14ContentVisitorEBb_'
 #0 0x00007f7353ec49ca llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib64/libLLVM-16.so+0xcc49ca)
 #1 0x00007f7353ec2354 llvm::sys::RunSignalHandlers() (/lib64/libLLVM-16.so+0xcc2354)
 #2 0x00007f7353ec557b (/lib64/libLLVM-16.so+0xcc557b)
 #3 0x00007f7352a3e9a0 __restore_rt (/lib64/libc.so.6+0x3e9a0)
 #4 0x00007f7352a90824 __pthread_kill_implementation (/lib64/libc.so.6+0x90824)
 #5 0x00007f7352a3e8ee gsignal (/lib64/libc.so.6+0x3e8ee)
 #6 0x00007f7352a268ff abort (/lib64/libc.so.6+0x268ff)
 #7 0x00007f7352edf1e0 __gnu_debug::_Safe_sequence_base::_M_get_mutex() (/lib64/libstdc++.so.6+0xdf1e0)
 #8 0x00007f73548b341c (/lib64/libLLVM-16.so+0x16b341c)
 #9 0x00007f73548b3766 (/lib64/libLLVM-16.so+0x16b3766)
#10 0x00007f7354897fe1 llvm::DbgVariable::getFrameIndexExprs() const (/lib64/libLLVM-16.so+0x1697fe1)
#11 0x00007f73548912b6 llvm::DwarfCompileUnit::constructVariableDIEImpl(llvm::DbgVariable const&, bool) (/lib64/libLLVM-16.so+0x16912b6)
#12 0x00007f73548901b2 llvm::DwarfCompileUnit::createAndAddScopeChildren(llvm::LexicalScope*, llvm::DIE&) (/lib64/libLLVM-16.so+0x16901b2)
#13 0x00007f73548904c0 llvm::DwarfCompileUnit::createAndAddScopeChildren(llvm::LexicalScope*, llvm::DIE&) (/lib64/libLLVM-16.so+0x16904c0)
#14 0x00007f735489062e llvm::DwarfCompileUnit::createAndAddScopeChildren(llvm::LexicalScope*, llvm::DIE&) (/lib64/libLLVM-16.so+0x169062e)
#15 0x00007f735489062e llvm::DwarfCompileUnit::createAndAddScopeChildren(llvm::LexicalScope*, llvm::DIE&) (/lib64/libLLVM-16.so+0x169062e)
#16 0x00007f73548904c0 llvm::DwarfCompileUnit::createAndAddScopeChildren(llvm::LexicalScope*, llvm::DIE&) (/lib64/libLLVM-16.so+0x16904c0)
#17 0x00007f7354892533 llvm::DwarfCompileUnit::constructSubprogramScopeDIE(llvm::DISubprogram const*, llvm::LexicalScope*) (/lib64/libLLVM-16.so+0x1692533)
#18 0x00007f73548a5c3b llvm::DwarfDebug::endFunctionImpl(llvm::MachineFunction const*) (/lib64/libLLVM-16.so+0x16a5c3b)
#19 0x00007f7354882a76 llvm::DebugHandlerBase::endFunction(llvm::MachineFunction const*) (/lib64/libLLVM-16.so+0x1682a76)
#20 0x00007f735486b34c llvm::AsmPrinter::emitFunctionBody() (/lib64/libLLVM-16.so+0x166b34c)
#21 0x00007f7356de8d25 (/lib64/libLLVM-16.so+0x3be8d25)
#22 0x00007f73542e219c llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/lib64/libLLVM-16.so+0x10e219c)
#23 0x00007f7354035a5e llvm::FPPassManager::runOnFunction(llvm::Function&) (/lib64/libLLVM-16.so+0xe35a5e)
#24 0x00007f735403c853 llvm::FPPassManager::runOnModule(llvm::Module&) (/lib64/libLLVM-16.so+0xe3c853)
#25 0x00007f73540361da llvm::legacy::PassManagerImpl::run(llvm::Module&) (/lib64/libLLVM-16.so+0xe361da)
#26 0x000000000041096a main (/usr/bin/llc+0x41096a)
#27 0x00007f7352a2814a __libc_start_call_main (/lib64/libc.so.6+0x2814a)
#28 0x00007f7352a2820b __libc_start_main.5 (/lib64/libc.so.6+0x2820b)
#29 0x000000000040d9e5 _start (/usr/bin/llc+0x40d9e5)
Aborted (core dumped)



Reproducible on both llvm-16.0.6-4.fc39.x86_64 and llvm-16.0.6-1.fc38.x86_64.

Comment 1 Josh Stone 2023-07-26 00:35:39 UTC
Created attachment 1979987 [details]
reduced.bc

Comment 2 Josh Stone 2023-07-26 00:41:03 UTC
Here's a fuller backtrace from GDB:

(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007ffff04b08b3 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007ffff045fabe in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff044887f in __GI_abort () at abort.c:79
#4  0x00007ffff06df1e0 in std::__glibcxx_assert_fail (file=<optimized out>, line=<optimized out>, function=<optimized out>, condition=<optimized out>) at ../../../../../libstdc++-v3/src/c++11/debug.cc:61
#5  0x00007ffff20b256c in llvm::DbgVariable::getFrameIndexExprs() const::$_0::operator()(llvm::DbgVariable::FrameIndexExpr const&, llvm::DbgVariable::FrameIndexExpr const&) const (A=..., B=..., this=<optimized out>)
    at /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/predefined_ops.h:158
#6  __gnu_cxx::__ops::_Iter_comp_iter<llvm::DbgVariable::getFrameIndexExprs() const::$_0>::operator()<llvm::DbgVariable::FrameIndexExpr*, llvm::DbgVariable::FrameIndexExpr*>(llvm::DbgVariable::FrameIndexExpr*, llvm::DbgVariable::FrameIndexExpr*) (
    this=<optimized out>, __it1=<optimized out>, __it2=<optimized out>) at /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/predefined_ops.h:158
#7  0x00007ffff20b28b6 in std::__insertion_sort<llvm::DbgVariable::FrameIndexExpr*, __gnu_cxx::__ops::_Iter_comp_iter<llvm::DbgVariable::getFrameIndexExprs() const::$_0> >(llvm::DbgVariable::FrameIndexExpr*, llvm::DbgVariable::FrameIndexExpr*, __gnu_cxx::__ops::_Iter_comp_iter<llvm::DbgVariable::getFrameIndexExprs() const::$_0>) (__first=0x5cb490, __last=0x5cb4b0, __comp=...) at /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/stl_algo.h:1819
#8  0x00007ffff2096e61 in std::__final_insertion_sort<llvm::DbgVariable::FrameIndexExpr*, __gnu_cxx::__ops::_Iter_comp_iter<llvm::DbgVariable::getFrameIndexExprs() const::$_0> >(llvm::DbgVariable::FrameIndexExpr*, llvm::DbgVariable::FrameIndexExpr*, __gnu_cxx::__ops::_Iter_comp_iter<llvm::DbgVariable::getFrameIndexExprs() const::$_0>) (__first=0x5cb490, __last=0x5cb4b0, __comp=...) at /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/stl_algo.h:1864
#9  std::__sort<llvm::DbgVariable::FrameIndexExpr*, __gnu_cxx::__ops::_Iter_comp_iter<llvm::DbgVariable::getFrameIndexExprs() const::$_0> >(llvm::DbgVariable::FrameIndexExpr*, llvm::DbgVariable::FrameIndexExpr*, __gnu_cxx::__ops::_Iter_comp_iter<llvm::DbgVariable::getFrameIndexExprs() const::$_0>) (__first=0x5cb490, __last=0x5cb4b0, __comp=...) at /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/stl_algo.h:1950
#10 std::sort<llvm::DbgVariable::FrameIndexExpr*, llvm::DbgVariable::getFrameIndexExprs() const::$_0>(llvm::DbgVariable::FrameIndexExpr*, llvm::DbgVariable::FrameIndexExpr*, llvm::DbgVariable::getFrameIndexExprs() const::$_0) (__first=0x5cb490,
    __last=0x5cb4b0, __comp=...) at /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/stl_algo.h:4894
#11 llvm::sort<llvm::DbgVariable::FrameIndexExpr*, llvm::DbgVariable::getFrameIndexExprs() const::$_0>(llvm::DbgVariable::FrameIndexExpr*, llvm::DbgVariable::FrameIndexExpr*, llvm::DbgVariable::getFrameIndexExprs() const::$_0) (Start=0x5cb490,
    End=0x5cb4b0, Comp=...) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/include/llvm/ADT/STLExtras.h:1705
#12 llvm::sort<llvm::SmallVector<llvm::DbgVariable::FrameIndexExpr, 1u>&, llvm::DbgVariable::getFrameIndexExprs() const::$_0>(llvm::SmallVector<llvm::DbgVariable::FrameIndexExpr, 1u>&, llvm::DbgVariable::getFrameIndexExprs() const::$_0) (C=...,
    Comp=...) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/include/llvm/ADT/STLExtras.h:1710
#13 llvm::DbgVariable::getFrameIndexExprs (this=0x5cd630) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:282
#14 0x00007ffff2090136 in llvm::DwarfCompileUnit::constructVariableDIEImpl (this=0x5339a0, DV=..., Abstract=<optimized out>) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:853
#15 0x00007ffff208f032 in llvm::DwarfCompileUnit::constructVariableDIE (this=0x5339a0, DV=..., Abstract=<optimized out>) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:706
#16 llvm::DwarfCompileUnit::constructVariableDIE (this=0x5339a0, DV=..., Scope=..., ObjectPointer=<optimized out>) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:911
#17 llvm::DwarfCompileUnit::createAndAddScopeChildren (this=0x5339a0, Scope=0x5cbca8, ScopeDIE=...) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:1063
#18 0x00007ffff208d731 in llvm::DwarfCompileUnit::constructScopeDIE (this=0x195333, Scope=0x195333, ParentScopeDIE=...) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/include/llvm/CodeGen/DIE.h:540
#19 0x00007ffff208f340 in llvm::DwarfCompileUnit::createAndAddScopeChildren (this=0x5339a0, Scope=<optimized out>, ScopeDIE=...) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:1091
#20 0x00007ffff208f4ae in llvm::DwarfCompileUnit::createAndAddScopeChildren (this=0x5339a0, Scope=<optimized out>, ScopeDIE=...) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:1093
#21 0x00007ffff208f4ae in llvm::DwarfCompileUnit::createAndAddScopeChildren (this=0x5339a0, Scope=<optimized out>, ScopeDIE=...) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:1093
#22 0x00007ffff208d731 in llvm::DwarfCompileUnit::constructScopeDIE (this=0x195333, Scope=0x195333, ParentScopeDIE=...) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/include/llvm/CodeGen/DIE.h:540
#23 0x00007ffff208f340 in llvm::DwarfCompileUnit::createAndAddScopeChildren (this=0x5339a0, Scope=<optimized out>, ScopeDIE=...) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:1091
#24 0x00007ffff20913b3 in llvm::DwarfCompileUnit::constructSubprogramScopeDIE (this=0x5339a0, Sub=0x44c140, Scope=0x5cba10) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:1032
#25 0x00007ffff20a4cdb in llvm::DwarfDebug::endFunctionImpl (this=0x531dc0, MF=0x596180) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2296
#26 0x00007ffff20819c6 in llvm::DebugHandlerBase::endFunction (this=0x531dc0, MF=0x596180) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp:410
#27 0x00007ffff206a117 in llvm::AsmPrinter::emitFunctionBody (this=0x4f7680) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1842
#28 0x00007ffff45f5665 in llvm::X86AsmPrinter::runOnMachineFunction (this=0x4f7680, MF=...) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/Target/X86/X86AsmPrinter.cpp:86
#29 0x00007ffff1adf53c in llvm::MachineFunctionPass::runOnFunction (this=0x4f7680, F=...) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/CodeGen/MachineFunctionPass.cpp:91
#30 0x00007ffff18335ae in llvm::FPPassManager::runOnFunction (this=0x4cfdd0, F=...) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/IR/LegacyPassManager.cpp:1430
#31 0x00007ffff183a303 in llvm::FPPassManager::runOnModule (this=0x4cfdd0, M=...) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/IR/LegacyPassManager.cpp:1476
#32 0x00007ffff1833d2a in (anonymous namespace)::MPPassManager::runOnModule (this=0x4cdf20, M=...) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/IR/LegacyPassManager.cpp:1545
#33 llvm::legacy::PassManagerImpl::run (this=0x4b21b0, M=...) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/lib/IR/LegacyPassManager.cpp:535
#34 0x000000000041096a in compileModule (argv=<optimized out>, Context=...) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/tools/llc/llc.cpp:733
#35 main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/llvm-16.0.6-1.fc38.x86_64/tools/llc/llc.cpp:420

Comment 3 Nikita Popov 2023-07-27 08:53:41 UTC
I've filed https://github.com/llvm/llvm-project/issues/64149 with a slightly reduced test case.

Comment 4 Josh Stone 2023-07-27 19:40:21 UTC
Created attachment 1980333 [details]
original reproducer

Comment 5 Nikita Popov 2023-07-28 14:35:26 UTC
Do you also have the cargo-50f78329f19490ae.cargo.c1756bb5859f0146-cgu.10.rcgu.no-opt.bc file? I'd like to check whether the issue already exists in the input IR or only appears after optimization.

(The rust srpm would also work, it looks like the original copr link expired.)

Comment 6 Josh Stone 2023-07-28 19:55:58 UTC
Created attachment 1980523 [details]
original no-opt reproducer

Comment 7 Josh Stone 2023-07-28 20:01:53 UTC
I attached the no-opt, and uploaded the srpm here:
https://jistone.fedorapeople.org/bz2226564/rust-1.71.0-2.fc39.src.rpm

That verrel is not correct -- it's really a 1.73-nightly inside. If you build it in mock, it needs --enable-network to download beta stage0.

Comment 8 Fedora Release Engineering 2023-08-16 08:13:35 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 39 development cycle.
Changing version to 39.

Comment 9 Josh Stone 2023-08-21 22:45:27 UTC
This problem has now appeared in a scratch build of rust-1.72.0~beta.11:
https://koji.fedoraproject.org/koji/taskinfo?taskID=105099384


Note You need to log in before you can comment on or make changes to this bug.