Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Segfault in opt-3.7 when running "Combine redundant instructions" pass #25118

Open Quuxplusone opened 9 years ago

Quuxplusone commented 9 years ago
Bugzilla Link PR25119
Status NEW
Importance P normal
Reported by Erik (erikd@mega-nerd.com)
Reported on 2015-10-09 01:40:27 -0700
Last modified on 2015-10-09 04:18:19 -0700
Version 3.7
Hardware PC Linux
CC llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments HeapStackCheck.ll (2098 bytes, application/octet-stream)
HeapStackCheck.ll (100394 bytes, application/octet-stream)
Blocks
Blocked by
See also

Created attachment 15040 File that causes the segfault

Attached file run with:

 /usr/bin/opt-3.7 rts/HeapStackCheck.ll -o /dev/null -O2

segfaults as follows:

$ /usr/bin/opt-3.7 rts/HeapStackCheck.ll -o /dev/null -O2 0 libLLVM-3.7.so.1 0x00007fed8d11735d llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 45 1 libLLVM-3.7.so.1 0x00007fed8d116961 2 libpthread.so.0 0x00007fed8b9d78d0 3 libLLVM-3.7.so.1 0x00007fed8d272110 llvm::MDNode::getMostGenericTBAA(llvm::MDNode, llvm::MDNode) + 352 4 libLLVM-3.7.so.1 0x00007fed8d4dc748 llvm::combineMetadata(llvm::Instruction, llvm::Instruction const, llvm::ArrayRef) + 488 5 libLLVM-3.7.so.1 0x00007fed8c7b4d2a 6 libLLVM-3.7.so.1 0x00007fed8c808762 7 libLLVM-3.7.so.1 0x00007fed8c809aa3 8 libLLVM-3.7.so.1 0x00007fed8c80a01c 9 libLLVM-3.7.so.1 0x00007fed8c402c37 llvm::FPPassManager::runOnFunction(llvm::Function&) + 471 10 libLLVM-3.7.so.1 0x00007fed8c402e8b llvm::FPPassManager::runOnModule(llvm::Module&) + 43 11 libLLVM-3.7.so.1 0x00007fed8c4028c4 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 756 12 opt-3.7 0x000000000041b643 main + 7411 13 libc.so.6 0x00007fed8a53cb45 __libc_start_main + 245 14 opt-3.7 0x000000000041b834 Stack dump:

  1. Program arguments: /usr/bin/opt-3.7 rts/HeapStackCheck.ll -o /dev/null -O2
  2. Running pass 'Function Pass Manager' on module 'rts/HeapStackCheck.ll'.
  3. Running pass 'Combine redundant instructions' on function '@"stg_gc_noregs$def"' Segmentation fault

The binary is from the llvm-3.7 package in Debian testing.

Quuxplusone commented 9 years ago

Attached HeapStackCheck.ll (2098 bytes, application/octet-stream): File that causes the segfault

Quuxplusone commented 9 years ago

Attached HeapStackCheck.ll (100394 bytes, application/octet-stream): Full test case (did not try to reduce it)

Quuxplusone commented 9 years ago
Fiora on IRC determined the probelm was the metadata definition and suggested
replacing this:

    !0 = !{!"top", i8* null}
    !1 = !{!"stack", !0}
    !2 = !{!"heap", !0}
    !3 = !{!"rx", !2}
    !4 = !{!"base", !0}
    !5 = !{!"other", !0}

with this

    !0 = !{!"top", null}
    !1 = !{!6, !6, i64 0}
    !2 = !{!7, !7, i64 0}
    !3 = !{!8, !8, i64 0}
    !4 = !{!9, !9, i64 0}
    !5 = !{!10, !10, i64 0}
    !6 = !{!"stack", !0}
    !7 = !{!"heap", !0}
    !8 = !{!"rx", !7}
    !9 = !{!"base", !0}
    !10 = !{!"other", !0}

I have no idea why this works and why what I had (which worked with llvm 3.6)
doesn't.
Quuxplusone commented 9 years ago
Turns out all I need to do to prevent triggering the assert was changing:

    !0 = !{!"top", i8* null}

to

    !0 = !{!"top", null}