llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.84k stars 11.47k forks source link

Possible valgrind error in LiveDebugValues #29005

Open llvmbot opened 8 years ago

llvmbot commented 8 years ago
Bugzilla Link 28631
Version trunk
OS Linux
Attachments C source code
Reporter LLVM Bugzilla Contributor

Extended Description

The attached C code, when compiled by recent clang, and the flags -g -O3, does this:

==2065== Conditional jump or move depends on uninitialised value(s)
==2065==    at 0x2530C8E: std::_Rb_tree<(anonymous namespace)::LiveDebugValues::VarLoc, std::pair<(anonymous namespace)::LiveDebugValues::VarLoc const, unsigned int>, std::_Select1st<std::pair<(anonymous namespace)::LiveDebugValues::VarLoc const, unsigned int> >, std::less<(anonymous namespace)::LiveDebugValues::VarLoc>, std::allocator<std::pair<(anonymous namespace)::LiveDebugValues::VarLoc const, unsigned int> > >::_M_lower_bound(std::_Rb_tree_node<std::pair<(anonymous namespace)::LiveDebugValues::VarLoc const, unsigned int> >*, std::_Rb_tree_node_base*, (anonymous namespace)::LiveDebugValues::VarLoc const&) (stl_tree.h:1624)
==2065==    by 0x253031C: std::_Rb_tree<(anonymous namespace)::LiveDebugValues::VarLoc, std::pair<(anonymous namespace)::LiveDebugValues::VarLoc const, unsigned int>, std::_Select1st<std::pair<(anonymous namespace)::LiveDebugValues::VarLoc const, unsigned int> >, std::less<(anonymous namespace)::LiveDebugValues::VarLoc>, std::allocator<std::pair<(anonymous namespace)::LiveDebugValues::VarLoc const, unsigned int> > >::lower_bound((anonymous namespace)::LiveDebugValues::VarLoc const&) (stl_tree.h:1098)
==2065==    by 0x252FDD4: std::map<(anonymous namespace)::LiveDebugValues::VarLoc, unsigned int, std::less<(anonymous namespace)::LiveDebugValues::VarLoc>, std::allocator<std::pair<(anonymous namespace)::LiveDebugValues::VarLoc const, unsigned int> > >::lower_bound((anonymous namespace)::LiveDebugValues::VarLoc const&) (stl_map.h:1150)
==2065==    by 0x252FA9B: std::map<(anonymous namespace)::LiveDebugValues::VarLoc, unsigned int, std::less<(anonymous namespace)::LiveDebugValues::VarLoc>, std::allocator<std::pair<(anonymous namespace)::LiveDebugValues::VarLoc const, unsigned int> > >::operator[]((anonymous namespace)::LiveDebugValues::VarLoc const&) (stl_map.h:479)
==2065==    by 0x252F8A4: llvm::UniqueVector<(anonymous namespace)::LiveDebugValues::VarLoc>::insert((anonymous namespace)::LiveDebugValues::VarLoc const&) (UniqueVector.h:44)
==2065==    by 0x252E25E: (anonymous namespace)::LiveDebugValues::transferDebugValue(llvm::MachineInstr const&, (anonymous namespace)::LiveDebugValues::OpenRangesSet&, llvm::UniqueVector<(anonymous namespace)::LiveDebugValues::VarLoc>&) (LiveDebugValues.cpp:298)
==2065==    by 0x252E83D: (anonymous namespace)::LiveDebugValues::transfer(llvm::MachineInstr&, (anonymous namespace)::LiveDebugValues::OpenRangesSet&, llvm::SmallDenseMap<llvm::MachineBasicBlock const*, llvm::SparseBitVector<128u>, 4u, llvm::DenseMapInfo<llvm::MachineBasicBlock const*>, llvm::detail::DenseMapPair<llvm::MachineBasicBlock const*, llvm::SparseBitVector<128u> > >&, llvm::UniqueVector<(anonymous namespace)::LiveDebugValues::VarLoc>&) (LiveDebugValues.cpp:361)
==2065==    by 0x252F0DD: (anonymous namespace)::LiveDebugValues::ExtendRanges(llvm::MachineFunction&) (LiveDebugValues.cpp:449)
==2065==    by 0x252F7E4: (anonymous namespace)::LiveDebugValues::runOnMachineFunction(llvm::MachineFunction&) (LiveDebugValues.cpp:513)
==2065==    by 0x25A595D: llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (MachineFunctionPass.cpp:60)
==2065==    by 0x28EE590: llvm::FPPassManager::runOnFunction(llvm::Function&) (LegacyPassManager.cpp:1526)
==2065==    by 0x28EE707: llvm::FPPassManager::runOnModule(llvm::Module&) (LegacyPassManager.cpp:1547)
==2065== 
$ ~/llvm/results/bin/clang -v
clang version 4.0.0 (trunk 276092) (llvm/trunk 276091)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/dcb/llvm/results/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/6.1.1
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/6.1.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
[dcb@dhcppc1 SRC]$
llvmbot commented 1 month ago

@llvm/issue-subscribers-debuginfo

Author: None (llvmbot)

| | | | --- | --- | | Bugzilla Link | [28631](https://llvm.org/bz28631) | | Version | trunk | | OS | Linux | | Attachments | [C source code](https://user-images.githubusercontent.com/60944935/143753962-382eb1ad-59a6-4fce-8516-2f26f9931646.gz) | | Reporter | LLVM Bugzilla Contributor | ## Extended Description The attached C code, when compiled by recent clang, and the flags `-g -O3`, does this: ``` ==2065== Conditional jump or move depends on uninitialised value(s) ==2065== at 0x2530C8E: std::_Rb_tree<(anonymous namespace)::LiveDebugValues::VarLoc, std::pair<(anonymous namespace)::LiveDebugValues::VarLoc const, unsigned int>, std::_Select1st<std::pair<(anonymous namespace)::LiveDebugValues::VarLoc const, unsigned int> >, std::less<(anonymous namespace)::LiveDebugValues::VarLoc>, std::allocator<std::pair<(anonymous namespace)::LiveDebugValues::VarLoc const, unsigned int> > >::_M_lower_bound(std::_Rb_tree_node<std::pair<(anonymous namespace)::LiveDebugValues::VarLoc const, unsigned int> >*, std::_Rb_tree_node_base*, (anonymous namespace)::LiveDebugValues::VarLoc const&) (stl_tree.h:1624) ==2065== by 0x253031C: std::_Rb_tree<(anonymous namespace)::LiveDebugValues::VarLoc, std::pair<(anonymous namespace)::LiveDebugValues::VarLoc const, unsigned int>, std::_Select1st<std::pair<(anonymous namespace)::LiveDebugValues::VarLoc const, unsigned int> >, std::less<(anonymous namespace)::LiveDebugValues::VarLoc>, std::allocator<std::pair<(anonymous namespace)::LiveDebugValues::VarLoc const, unsigned int> > >::lower_bound((anonymous namespace)::LiveDebugValues::VarLoc const&) (stl_tree.h:1098) ==2065== by 0x252FDD4: std::map<(anonymous namespace)::LiveDebugValues::VarLoc, unsigned int, std::less<(anonymous namespace)::LiveDebugValues::VarLoc>, std::allocator<std::pair<(anonymous namespace)::LiveDebugValues::VarLoc const, unsigned int> > >::lower_bound((anonymous namespace)::LiveDebugValues::VarLoc const&) (stl_map.h:1150) ==2065== by 0x252FA9B: std::map<(anonymous namespace)::LiveDebugValues::VarLoc, unsigned int, std::less<(anonymous namespace)::LiveDebugValues::VarLoc>, std::allocator<std::pair<(anonymous namespace)::LiveDebugValues::VarLoc const, unsigned int> > >::operator[]((anonymous namespace)::LiveDebugValues::VarLoc const&) (stl_map.h:479) ==2065== by 0x252F8A4: llvm::UniqueVector<(anonymous namespace)::LiveDebugValues::VarLoc>::insert((anonymous namespace)::LiveDebugValues::VarLoc const&) (UniqueVector.h:44) ==2065== by 0x252E25E: (anonymous namespace)::LiveDebugValues::transferDebugValue(llvm::MachineInstr const&, (anonymous namespace)::LiveDebugValues::OpenRangesSet&, llvm::UniqueVector<(anonymous namespace)::LiveDebugValues::VarLoc>&) (LiveDebugValues.cpp:298) ==2065== by 0x252E83D: (anonymous namespace)::LiveDebugValues::transfer(llvm::MachineInstr&, (anonymous namespace)::LiveDebugValues::OpenRangesSet&, llvm::SmallDenseMap<llvm::MachineBasicBlock const*, llvm::SparseBitVector<128u>, 4u, llvm::DenseMapInfo<llvm::MachineBasicBlock const*>, llvm::detail::DenseMapPair<llvm::MachineBasicBlock const*, llvm::SparseBitVector<128u> > >&, llvm::UniqueVector<(anonymous namespace)::LiveDebugValues::VarLoc>&) (LiveDebugValues.cpp:361) ==2065== by 0x252F0DD: (anonymous namespace)::LiveDebugValues::ExtendRanges(llvm::MachineFunction&) (LiveDebugValues.cpp:449) ==2065== by 0x252F7E4: (anonymous namespace)::LiveDebugValues::runOnMachineFunction(llvm::MachineFunction&) (LiveDebugValues.cpp:513) ==2065== by 0x25A595D: llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (MachineFunctionPass.cpp:60) ==2065== by 0x28EE590: llvm::FPPassManager::runOnFunction(llvm::Function&) (LegacyPassManager.cpp:1526) ==2065== by 0x28EE707: llvm::FPPassManager::runOnModule(llvm::Module&) (LegacyPassManager.cpp:1547) ==2065== ``` ```console $ ~/llvm/results/bin/clang -v clang version 4.0.0 (trunk 276092) (llvm/trunk 276091) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/dcb/llvm/results/bin Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/6.1.1 Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/6.1.1 Candidate multilib: .;@m64 Candidate multilib: 32;@m32 Selected multilib: .;@m64 [dcb@dhcppc1 SRC]$ ```
jmorse commented 1 month ago

Probably fixed in the last 8 years or so, for example in a3bc043caaa , but I've no time to check properly. Just a note to anyone reading this ticket that the implementation referred to here lives on in llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp, and isn't the default on x86 any more.