How to use valgrind effectively

I just started learning to use valgrind and --tool = memcheck

But I am having trouble finding problems.

eg.

One such problem.

==12561== Conditional jump or move depends on uninitialised value(s)
==12561==    at 0x425779: Server::HandleReceiveFrom(boost::system::error_code const&, unsigned long) (mUUID.h:63)
==12561==    by 0x428EC4: boost::asio::detail::reactive_socket_recvfrom_op<boost::asio::mutable_buffers_1, boost::asio::ip::basic_endpoint<boost::asio::ip::udp>, boost::_bi::bind_t<void, boost::_mfi::mf2<void, Server, boost::system::error_code const&, unsigned long>, boost::_bi::list3<boost::_bi::value<Server*>, boost::arg<1> (*)(), boost::arg<2> (*)()> > >::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&) (task_io_service_operation.hpp:35)
==12561==    by 0x42720C: Server::Run() (io_service.ipp:57)
==12561==    by 0x42FB00: main (obbs.cpp:198)

and the other -

== 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)

After some tips on how to most effectively track these issues. (Conditional jumps and uninitialized values.)

EDIT

Is there anything to worry about? It seems to fade with the option --run-libc-freeres=no. Does this mean that I have an invalid C library?

==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
+5
source share
1 answer

, Valgrind . , . . , ( ). , , 198 obbs.cpp - , . , 63 mUUID.h if, .

"Conditional jump or move depends on uninitialised value(s)" , , . , Boost, , . , undefined.

, , :

int i; // uninitialized value
if (i == 10) { /* ... do something */ }

198 obbs.cpp , .

, , . ( GCC, , , -Wall)

+15
source

All Articles