[llvm-bugs] [Bug 32190] New: Assertion fails in debug mode with totally valid LLVM module Due to invalid FragmentInfo

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 8 19:04:23 PST 2017


http://bugs.llvm.org/show_bug.cgi?id=32190

            Bug ID: 32190
           Summary: Assertion fails in debug mode with totally valid LLVM
                    module Due to invalid FragmentInfo
           Product: new-bugs
           Version: 4.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: russellgreene8 at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 18070
  --> http://bugs.llvm.org/attachment.cgi?id=18070&action=edit
The module that crashes lli

I get an assertion when running this module with lli:

llvm/ADT/Optional.h:120: T* llvm::Optional<T>::getPointer() [with T =
llvm::DIExpression::FragmentInfo]: Assertion `hasVal' failed.


Here's the module:
(https://gist.github.com/russelltg/69041e162f520de403cf4af41f248a39, plus
they're attacked)

; ModuleID = 'if/main'
source_filename = "if/main"
target triple = "x86_64-unknown-linux-gnu"

define i32 @main() !dbg !5 {
  %myvar = alloca i32
  call void @llvm.dbg.declare(metadata i32* %myvar, metadata !15, metadata
!10), !dbg !14

  store i32 2, i32* %myvar, !dbg !23
  ret i32 0

}

; Function Attrs: nounwind readnone
declare void @llvm.dbg.declare(metadata, metadata, metadata) #0

!llvm.module.flags = !{!0}
!llvm.dbg.cu = !{!1}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "Chigraph
Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug,
enums: !3)
!2 = !DIFile(filename: "main.chigmod", directory:
"/home/russellg/projects/chigraph/test/codegen/workspace/src/if")
!3 = !{}
!5 = distinct !DISubprogram(name: "if/main:main", linkageName: "main", scope:
!2, file: !2, line: 5, type: !6, isLocal: false, isDefinition: true,
isOptimized: false, unit: !1, variables: !3)
!6 = !DISubroutineType(types: !7)
!7 = !{!8, !8}
!8 = !DIBasicType(name: "lang:i32", size: 32, align: 32, encoding:
DW_ATE_signed)
!10 = !DIExpression()
!14 = !DILocation(line: 1, column: 1, scope: !5)
!15 = !DILocalVariable(name: "myvar", scope: !5, file: !2, line: 1, type: !8)
!23 = !DILocation(line: 8, column: 1, scope: !5)



And here's the stack trace:

* thread #1: tid = 21094, 0x00007fffef52404f libc.so.6`__GI_raise + 207, name =
'lli', stop reason = signal SIGABRT
  * frame #0: 0x00007fffef52404f libc.so.6`__GI_raise + 207
    frame #1: 0x00007fffef52547a libc.so.6`__GI_abort + 362
    frame #2: 0x00007fffef51cea7 libc.so.6`__assert_fail_base + 279
    frame #3: 0x00007fffef51cf52 libc.so.6`__GI___assert_fail + 66
    frame #4: 0x00007ffff238bec1
libLLVM-4.0.so`llvm::Optional<llvm::DIExpression::FragmentInfo>::getPointer(this=0x00007fffffffa790)
+ 55 at Optional.h:120
    frame #5: 0x00007ffff2384d1e
libLLVM-4.0.so`llvm::Optional<llvm::DIExpression::FragmentInfo>::operator->(this=0x00007fffffffa790)
+ 24 at Optional.h:127
    frame #6: 0x00007ffff2b628d4
libLLVM-4.0.so`operator(__closure=0x00007fffffffa820, A=0x00000000009161d0,
B=0x00000000009161d0) + 56 at DwarfDebug.cpp:205
    frame #7: 0x00007ffff2b6d7fb
libLLVM-4.0.so`std::sort<llvm::DbgVariable::FrameIndexExpr*,
llvm::DbgVariable::getFrameIndexExprs() const::<lambda(const
llvm::DbgVariable::FrameIndexExpr&, const llvm::DbgVariable::FrameIndexExpr&)>
>(__first=0x00000000009161d0, __last=0x00000000009161e0, __comp=<lambda(const
llvm::DbgVariable::FrameIndexExpr&, const llvm::DbgVariable::FrameIndexExpr&)>
@ 0x00007fffffffa820)>) + 166 at stl_algo.h:4737
    frame #8: 0x00007ffff2b62969
libLLVM-4.0.so`llvm::DbgVariable::getFrameIndexExprs(this=0x0000000000916190)
const + 67 at DwarfDebug.cpp:207
    frame #9: 0x00007ffff2b57fbb
libLLVM-4.0.so`llvm::DwarfCompileUnit::constructVariableDIEImpl(this=0x00000000008ac270,
DV=0x0000000000916190, Abstract=false) + 1333 at DwarfCompileUnit.cpp:530
    frame #10: 0x00007ffff2b57a68
libLLVM-4.0.so`llvm::DwarfCompileUnit::constructVariableDIE(this=0x00000000008ac270,
DV=0x0000000000916190, Abstract=false) + 44 at DwarfCompileUnit.cpp:466
    frame #11: 0x00007ffff2b5819e
libLLVM-4.0.so`llvm::DwarfCompileUnit::constructVariableDIE(this=0x00000000008ac270,
DV=0x0000000000916190, Scope=0x0000000000914ee0,
ObjectPointer=0x00007fffffffaa98) + 58 at DwarfCompileUnit.cpp:547
    frame #12: 0x00007ffff2b58290
libLLVM-4.0.so`llvm::DwarfCompileUnit::createScopeChildrenDIE(this=0x00000000008ac270,
Scope=0x0000000000914ee0, Children=0x00007fffffffabd0,
ChildScopeCount=0x0000000000000000) + 204 at DwarfCompileUnit.cpp:559
    frame #13: 0x00007ffff2b585c2
libLLVM-4.0.so`llvm::DwarfCompileUnit::createAndAddScopeChildren(this=0x00000000008ac270,
Scope=0x0000000000914ee0, ScopeDIE=0x00000000008ade60) + 82 at
DwarfCompileUnit.cpp:601
    frame #14: 0x00007ffff2b58490
libLLVM-4.0.so`llvm::DwarfCompileUnit::constructSubprogramScopeDIE(this=0x00000000008ac270,
Sub=0x0000000000865328, Scope=0x0000000000914ee0) + 176 at
DwarfCompileUnit.cpp:581
    frame #15: 0x00007ffff2b68abc
libLLVM-4.0.so`llvm::DwarfDebug::endFunction(this=0x00000000008aa1d0,
MF=0x00000000008d5370) + 1646 at DwarfDebug.cpp:1256
    frame #16: 0x00007ffff2b063fb
libLLVM-4.0.so`llvm::AsmPrinter::EmitFunctionBody(this=0x000000000089fc70) +
4381 at AsmPrinter.cpp:1015
    frame #17: 0x00007ffff488f47f
libLLVM-4.0.so`llvm::X86AsmPrinter::runOnMachineFunction(this=0x000000000089fc70,
MF=0x00000000008d5370) + 463 at X86AsmPrinter.cpp:70
    frame #18: 0x00007ffff25d42b0
libLLVM-4.0.so`llvm::MachineFunctionPass::runOnFunction(this=0x000000000089fc70,
F=0x0000000000860718) + 456 at MachineFunctionPass.cpp:62
    frame #19: 0x00007ffff22c9273
libLLVM-4.0.so`llvm::FPPassManager::runOnFunction(this=0x000000000087b520,
F=0x0000000000860718) + 315 at LegacyPassManager.cpp:1513
    frame #20: 0x00007ffff22c93ea
libLLVM-4.0.so`llvm::FPPassManager::runOnModule(this=0x000000000087b520,
M=0x000000000085ecc0) + 118 at LegacyPassManager.cpp:1534
    frame #21: 0x00007ffff22c975b libLLVM-4.0.so`(anonymous
namespace)::MPPassManager::runOnModule(this=0x0000000000869900,
M=0x000000000085ecc0) const + 647 at LegacyPassManager.cpp:1590
    frame #22: 0x00007ffff22c9e33
libLLVM-4.0.so`llvm::legacy::PassManagerImpl::run(this=0x0000000000869400,
M=0x000000000085ecc0) + 271 at LegacyPassManager.cpp:1693
    frame #23: 0x00007ffff22ca031
libLLVM-4.0.so`llvm::legacy::PassManager::run(this=0x00007fffffffc710,
M=0x000000000085ecc0) + 39 at LegacyPassManager.cpp:1724
    frame #24: 0x00007ffff3b07691
libLLVM-4.0.so`llvm::MCJIT::emitObject(this=0x0000000000868f70,
M=0x000000000085ecc0) + 257 at MCJIT.cpp:165
    frame #25: 0x00007ffff3b07943
libLLVM-4.0.so`llvm::MCJIT::generateCodeForModule(this=0x0000000000868f70,
M=0x000000000085ecc0) + 421 at MCJIT.cpp:204
    frame #26: 0x00007ffff3b07e13
libLLVM-4.0.so`llvm::MCJIT::finalizeObject(this=0x0000000000868f70) + 351 at
MCJIT.cpp:259
    frame #27: 0x0000000000530c52 lli`main(argc=2, argv=0x00007fffffffdf38,
envp=0x00007fffffffdf50) + 6564 at lli.cpp:615
    frame #28: 0x00007fffef511291 libc.so.6`__libc_start_main + 241
    frame #29: 0x000000000052e98a lli`_start + 42



This is with the release_40 branch which I pulled at ~00:00 UTC March 9. 

I compiled it with 


cmake ~/projects/llvm -DCMAKE_BUILD_TYPE=Debug \
    -DCMAKE_INSTALL_PREFIX=~/projects/llvm-debug \
    -GNinja \
    -DLLVM_ENABLE_CXX1Y=ON \
    -DLLVM_ENABLE_RTTI=ON \
    -DLLVM_ENABLE_LLD=ON \
    -DLLVM_LINK_LLVM_DYLIB=ON \
    -DLLVM_ENABLE_ASSERTIONS=ON \
    -DLLVM_ENABLE_EXPENSIVE_CHECKS=ON
ninja


On a fully updated arch linux install. 


That module is a stripped down version of something generated by my compiler. I
think it should be valid, and executes fine with a release build.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170309/c7bf5d21/attachment-0001.html>


More information about the llvm-bugs mailing list