title: How to use valgrind effectively
body: <p>I've just started learning to use valgrind and the --tool=memcheck</p>
  
  <p>But what I am having trouble with is actually finding the problems.</p>
  
  <p>e.g. </p>
  
  <p>One such problem is this.  </p>
  
  <pre><code>==12561== Conditional jump or move depends on uninitialised value(s)
  ==12561==    at 0x425779: Server::HandleReceiveFrom(boost::system::error_code const&amp;, unsigned long) (mUUID.h:63)
  ==12561==    by 0x428EC4: boost::asio::detail::reactive_socket_recvfrom_op&lt;boost::asio::mutable_buffers_1, boost::asio::ip::basic_endpoint&lt;boost::asio::ip::udp&gt;, boost::_bi::bind_t&lt;void, boost::_mfi::mf2&lt;void, Server, boost::system::error_code const&amp;, unsigned long&gt;, boost::_bi::list3&lt;boost::_bi::value&lt;Server*&gt;, boost::arg&lt;1&gt; (*)(), boost::arg&lt;2&gt; (*)()&gt; &gt; &gt;::do_complete(boost::asio::detail::task_io_service*, boost::asio::detail::task_io_service_operation*, boost::system::error_code, unsigned long) (mem_fn_template.hpp:280)
  ==12561==    by 0x42E589: boost::asio::detail::task_io_service::run(boost::system::error_code&amp;) (task_io_service_operation.hpp:35)
  ==12561==    by 0x42720C: Server::Run() (io_service.ipp:57)
  ==12561==    by 0x42FB00: main (obbs.cpp:198)
  </code></pre>
  
  <p>and another is this</p>
  
  <pre><code>== Use of uninitialised value of size 8
  ==12561==    at 0x5E56091: _itoa_word (_itoa.c:196)
  ==12561==    by 0x5E573D8: vfprintf (vfprintf.c:1613)
  ==12561==    by 0x5F0EA6F: __vsnprintf_chk (vsnprintf_chk.c:65)
  </code></pre>
  
  <p>I'm after some hints on how to most effectively trace these types of problems. (Conditional jumps and uninitialised values.)</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Is this anything to worry about?  Seems to disappear with the option <code>--run-libc-freeres=no</code>.
  Does that mean I have a buggy C library?</p>
  
  <pre><code>==14754== Invalid free() / delete / delete[]
  ==14754==    at 0x4C27D71: free (vg_replace_malloc.c:366)
  ==14754==    by 0x5F43A0A: free_mem (in /lib/libc-2.12.1.so)
  ==14754==    by 0x5F435A1: __libc_freeres (in /lib/libc-2.12.1.so)
  ==14754==    by 0x4A2366B: _vgnU_freeres (vg_preloaded.c:62)
  ==14754==    by 0x5E4A4A4: exit (exit.c:93)
  ==14754==    by 0x5E2FD94: (below main) (libc-start.c:258)
  ==14754==  Address 0x4046bb8 is not stack'd, malloc'd or (recently) free'd
  </code></pre>