[LLVMbugs] [Bug 20980] New: UBSan errors in MC/SystemZ (left shift of negative value)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Sep 17 13:09:27 PDT 2014


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

            Bug ID: 20980
           Summary: UBSan errors in MC/SystemZ (left shift of negative
                    value)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: SystemZ
          Assignee: unassignedbugs at nondot.org
          Reporter: vonosmas at gmail.com
                CC: llvmbugs at cs.uiuc.edu
            Blocks: 20815
    Classification: Unclassified

The following SystemZ tests fail under UBSan bootstrap of LLVM:

    LLVM :: MC/SystemZ/insn-bad-z196.s
    LLVM :: MC/SystemZ/insn-bad.s
    LLVM :: MC/SystemZ/insn-good-z196.s
    LLVM :: MC/SystemZ/insn-good.s

The problem seem to be left shifts of negative values in SystemZ, which are
evaluated directly by the MC layer (left shift of negative value is undefined
behavior in C).

Example error report:
llvm/lib/MC/MCExpr.cpp:802:43: runtime error: left shift of negative value -1
    #0 0x104bf21 in llvm::MCExpr::EvaluateAsRelocatableImpl(llvm::MCValue&,
llvm::MCAssembler const*, llvm::MCAsmLayout const*, llvm::MCFixup const*,
llvm::DenseMap<llvm::MCSectionData const*, unsigned long,
llvm::DenseMapInfo<llvm::MCSectionData const*> > const*, bool, bool) const
llvm/lib/MC/MCExpr.cpp:802:30
    #1 0x10499f1 in llvm::MCExpr::evaluateAsAbsolute(long&, llvm::MCAssembler
const*, llvm::MCAsmLayout const*, llvm::DenseMap<llvm::MCSectionData const*,
unsigned long, llvm::DenseMapInfo<llvm::MCSectionData const*> > const*, bool)
const llvm/lib/MC/MCExpr.cpp:499:24
    #2 0x10492b1 in llvm::MCExpr::EvaluateAsAbsolute(long&, llvm::MCAssembler
const*, llvm::MCAsmLayout const*, llvm::DenseMap<llvm::MCSectionData const*,
unsigned long, llvm::DenseMapInfo<llvm::MCSectionData const*> > const*) const
llvm/lib/MC/MCExpr.cpp:485:10
    #3 0x1049197 in llvm::MCExpr::EvaluateAsAbsolute(long&) const
llvm/lib/MC/MCExpr.cpp:452:10
    #4 0x11ae495 in (anonymous
namespace)::AsmParser::parseExpression(llvm::MCExpr const*&, llvm::SMLoc&)
llvm/lib/MC/MCParser/AsmParser.cpp:1051:7
    #5 0x12a813b in llvm::MCAsmParser::parseExpression(llvm::MCExpr const*&)
llvm/lib/MC/MCParser/MCAsmParser.cpp:43:10
    #6 0xd11359 in (anonymous
namespace)::SystemZAsmParser::parseAddress(unsigned int&, llvm::MCExpr const*&,
unsigned int&, llvm::MCExpr const*&, unsigned int const*, (anonymous
namespace)::RegisterKind)
llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp:500:7
    #7 0xd0e9a6 in (anonymous
namespace)::SystemZAsmParser::parseOperand(llvm::SmallVectorImpl<std::unique_ptr<llvm::MCParsedAsmOperand,
std::default_delete<llvm::MCParsedAsmOperand> > >&, llvm::StringRef)
llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp:665:7
    #8 0xcfe697 in (anonymous
namespace)::SystemZAsmParser::ParseInstruction(llvm::ParseInstructionInfo&,
llvm::StringRef, llvm::SMLoc,
llvm::SmallVectorImpl<std::unique_ptr<llvm::MCParsedAsmOperand,
std::default_delete<llvm::MCParsedAsmOperand> > >&)
llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp:616:11
    #9 0x11c2563 in (anonymous namespace)::AsmParser::parseStatement((anonymous
namespace)::ParseStatementInfo&) llvm/lib/MC/MCParser/AsmParser.cpp:1576:19
    #10 0x11a222c in (anonymous namespace)::AsmParser::Run(bool, bool)
llvm/lib/MC/MCParser/AsmParser.cpp:643:10
    #11 0x4494f0 in AssembleInput(char const*, llvm::Target const*,
llvm::SourceMgr&, llvm::MCContext&, llvm::MCStreamer&, llvm::MCAsmInfo&,
llvm::MCSubtargetInfo&, llvm::MCInstrInfo&, llvm::MCTargetOptions&)
llvm/tools/llvm-mc/llvm-mc.cpp:338:13
    #12 0x43d4ee in main llvm/tools/llvm-mc/llvm-mc.cpp:486:11
    #13 0x7fc2d9c4676c in __libc_start_main
/build/buildd/eglibc-2.15/csu/libc-start.c:226
    #14 0x420504 in _start (llvm_ubsan/bin/llvm-mc+0x420504)


To reproduce: build LLVM with just-built Clang and
-DLLVM_USE_SANITIZER=Undefined CMake option. I'm going to disable all
MC/SystemZ tests under UBSan in test/MC/SystemZ/lit.local.cfg, so that
suppression will have to be removed as well.

-- 
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/20140917/51c80366/attachment.html>


More information about the llvm-bugs mailing list