[LLVMbugs] [Bug 13929] New: UMR (uninitialized read) in llvm::APFloat::roundToIntegral

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Sep 26 06:08:41 PDT 2012


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

             Bug #: 13929
           Summary: UMR (uninitialized read) in
                    llvm::APFloat::roundToIntegral
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
        AssignedTo: kcc at google.com
        ReportedBy: kcc at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


clang r164661, 64-bit linux. 
The bug was found using MemorySanitizer while building proprietary code with
instrumented Clang/LLVM, then reduced with creduce. 

I am trying to figure out if this is harmful, but suggestions are welcome. 


% cat z.cc
extern "C" float floorf (float);
void foo (float);
void bar () {
  foo (floorf(0));
}
% ./bin/clang -c -O2 z.cc

==1233==  WARNING: MemorySanitizer: UMR (uninitialized-memory-read)
    #0 0x7ff45761cd02 in
llvm::APFloat::roundToIntegral(llvm::APFloat::roundingMode)
lib/Support/APFloat.cpp:1796:3
    #1 0x7ff456496b6d in llvm::SelectionDAG::getNode(unsigned int,
llvm::DebugLoc, llvm::EVT, llvm::SDValue)
lib/CodeGen/SelectionDAG/SelectionDAG.cpp:2503:32
    #2 0x7ff456579c65 in
llvm::SelectionDAGBuilder::visitUnaryFloatCall(llvm::CallInst const&, unsigned
int) lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:5605:54
    #3 0x7ff4565111da in llvm::SelectionDAGBuilder::visitCall(llvm::CallInst
const&) lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:5686:13
    #4 0x7ff4564feeeb in llvm::SelectionDAGBuilder::visit(unsigned int,
llvm::User const&) include/llvm/Instruction.def:164:1
    #5 0x7ff4564fd3e6 in llvm::SelectionDAGBuilder::visit(llvm::Instruction
const&) lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:940:9
    #6 0x7ff4565b34a1 in
llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::Instruction
const>, llvm::ilist_iterator<llvm::Instruction const>, bool&)
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:491:16
    #7 0x7ff4565b3111 in
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1160:7
    #8 0x7ff4565aec1a in
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:367:3
    #9 0x7ff4569243b4 in
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
lib/CodeGen/MachineFunctionPass.cpp:33:10
    #10 0x7ff4574e9a86 in llvm::FPPassManager::runOnFunction(llvm::Function&)
lib/VMCore/PassManager.cpp:1498:23
    #11 0x7ff4574ea17f in llvm::FPPassManager::runOnModule(llvm::Module&)
lib/VMCore/PassManager.cpp:1518:30
    #12 0x7ff4574ea811 in llvm::MPPassManager::runOnModule(llvm::Module&)
lib/VMCore/PassManager.cpp:1572:23
    #13 0x7ff4574eb32f in llvm::PassManagerImpl::run(llvm::Module&)
lib/VMCore/PassManager.cpp:1655:16
    #14 0x7ff4574eb746 in llvm::PassManager::run(llvm::Module&)
lib/VMCore/PassManager.cpp:1684:10
    #15 0x7ff45776ad0f in (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
llvm::raw_ostream*) tools/clang/lib/CodeGen/BackendUtil.cpp:478:5
    #16 0x7ff45776a37c in clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions
const&, llvm::Module*, clang::BackendAction, llvm::raw_ostream*)
tools/clang/lib/CodeGen/BackendUtil.cpp:490:3
    #17 0x7ff45776305a in
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
tools/clang/lib/CodeGen/CodeGenAction.cpp:160:25
    #18 0x7ff457e93f85 in clang::ParseAST(clang::Sema&, bool, bool)
tools/clang/lib/Parse/ParseAST.cpp:111:35
    #19 0x7ff457760745 in clang::CodeGenAction::ExecuteAction()
tools/clang/lib/CodeGen/CodeGenAction.cpp:421:3
    #20 0x7ff457cde310 in clang::FrontendAction::Execute()
tools/clang/lib/Frontend/FrontendAction.cpp:339:8
    #21 0x7ff457c7d3d1 in
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
tools/clang/lib/Frontend/CompilerInstance.cpp:672:7                             
    #22 0x7ff4577070fa in
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:189:38               
    #23 0x7ff45578190f in cc1_main(char const**, char const**, char const*,
void*) tools/clang/tools/driver/cc1_main.cpp:165:39                             
    #24 0x7ff45577334a in main tools/clang/tools/driver/driver.cpp:356:63
    #25 0x7ff454499c4c (/lib/libc.so.6+0x1ec4c)


The same report can be seen with valgrind: 

% valgrind --trace-children=yes --track-origins=yes clang -c -O2 z.cc
==1284== Conditional jump or move depends on uninitialised value(s)             
==1284==    at 0x10D4957:
llvm::APFloat::roundToIntegral(llvm::APFloat::roundingMode)                     
==1284==    by 0xA87B63: llvm::SelectionDAG::getNode(unsigned int,
llvm::DebugLoc, llvm::EVT, llvm::SDValue)                                       
==1284==    by 0xAB36C7:
llvm::SelectionDAGBuilder::visitUnaryFloatCall(llvm::CallInst const&, unsigned
int)                                                                            
==1284==    by 0xAA892A: llvm::SelectionDAGBuilder::visitCall(llvm::CallInst
const&)                                                                         
==1284==    by 0xAA8CFC: llvm::SelectionDAGBuilder::visit(unsigned int,
llvm::User const&)                                                              
==1284==    by 0xACCEBC: llvm::SelectionDAGBuilder::visit(llvm::Instruction
const&)                                                                         
==1284==    by 0xAD9017:
llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::Instruction
const>, llvm::ilist_iterator<llvm::Instruction const>, bool&)                   
==1284==    by 0xADAF2E:
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)             
==1284==    by 0xADC0D4:
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)            
==1284==    by 0x105BBB8: llvm::FPPassManager::runOnFunction(llvm::Function&)   
==1284==    by 0x105BC52: llvm::FPPassManager::runOnModule(llvm::Module&)       
==1284==    by 0x105B81D: llvm::MPPassManager::runOnModule(llvm::Module&)       
==1284==  Uninitialised value was created by a stack allocation                 
==1284==    at 0xFCC800: llvm::Constant::getNullValue(llvm::Type*)

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list