Boost logo

Boost :

Subject: Re: [boost] [chrono] Valgrind complains
From: Roland Bock (rbock_at_[hidden])
Date: 2010-06-23 02:05:06


vicente.botet wrote:
> ----- Original Message -----
> From: "Roland Bock" <rbock_at_[hidden]>
> To: <boost_at_[hidden]>
> Sent: Tuesday, June 22, 2010 8:23 PM
> Subject: Re: [boost] [chrono] Valgrind complains
>
>
>
>> vicente.botet wrote:
>>
>>> ----- Original Message -----
>>> From: "Roland Bock" <rbock_at_[hidden]>
>>> To: <boost_at_[hidden]>
>>> Sent: Tuesday, June 22, 2010 5:34 PM
>>> Subject: Re: [boost] [chrono] Valgrind complains
>>>
>>>
>>>
>>>
>>>>>> From: "Roland Bock" <rbock_at_[hidden]>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Valgrind complains about
>>>>>>>
>>>>>>> Conditional jump or move depends on uninitialised value(s)
>>>>>>>
>>>>>>>
>>>>>>> several times for the following line:
>>>>>>>
>>>>>>> { boost::chrono::stopclock<> stopclock(std::cerr); }
>>>>>>>
>>>>>>>
>>> Could you check if Valgrind complains with
>>>
>>> { boost::chrono::stopclock<> stopclock; }
>>> or
>>> { boost::chrono::stopclock<> stopclock(BOOST_CURRENT_FUNCTION); }
>>> or
>>> { boost::system::error_code ec;
>>> boost::chrono::stopclock<> stopclock(std::cerr, ec); }
>>>
>>> Thanks,
>>> Vicente
>>>
>>>
>>>
>>>
>> Hi,
>>
>> attached are
>>
>> * the source file containing the original test plus the three
>> additional tests suggested by you
>> * a file containing compiler warnings
>> * the valgrind output (the latter two tests do not produce warnings,
>> if I read it correctly)
>>
>>
>> The program was compiled using the following compiler flags (gcc=4.2.4
>> on Ubuntu 8.04, 64bit):
>>
>> -Wall -Wreorder -Wnon-virtual-dtor -Wno-non-template-friend
>> -Woverloaded-virtual -Wsign-promo -Wextra -fvisibility=hidden
>> -D_GNU_SOURCE -O0 -g
>>
>
>
> I have seen some places where the parameter system::error_code & ec is not initialized when the function succeed. I have update the code so the variable is initialized. Most of the tests are done with the default system::throws parameter so these errors are not catched. I will try to complete the tests for the no-throw cases soon.
>
> Roland, please could you download the new version, and check if the Valgrind issue is resolved?
>
> Thanks in advance,
> Vicente
>
Hi,

the compile warnings are gone, but valgrind stays unhappy.

I compiled libboost_chrono.so in debug mode, this time. This way,
valgrind's output should be more helpful inside the library's code, see
attachment.

Regards,

Roland


==11617== Memcheck, a memory error detector.
==11617== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==11617== Using LibVEX rev 1804, a library for dynamic binary translation.
==11617== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==11617== Using valgrind-3.3.0-Debian, a dynamic binary instrumentation framework.
==11617== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==11617== For more details, rerun with: -v
==11617==
==11617== Conditional jump or move depends on uninitialised value(s)
==11617== at 0x503B0B3: boost::chrono::duration<long, boost::ratio<1l, 1000000000l> >::operator=(boost::chrono::duration<long, boost::ratio<1l, 1000000000l> > const&) (chrono.hpp:538)
==11617== by 0x503AD3B: boost::chrono::process_clock::now(boost::chrono::process_clock::durations&, boost::system::error_code&) (process_clock.cpp:59)
==11617== by 0x503D5B4: boost::chrono::process_cpu_clock::now(boost::system::error_code&) (process_cpu_clocks.cpp:43)
==11617== by 0x4028F6: boost::chrono::stopwatch<boost::chrono::process_cpu_clock>::elapsed(boost::system::error_code&) (stopwatch.hpp:156)
==11617== by 0x402A63: void boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> >::show_time<boost::chrono::basic_stopwatch_reporter<boost::chrono::stopwatch<boost::chrono::process_cpu_clock>, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > > >(boost::chrono::basic_stopwatch_reporter<boost::chrono::stopwatch<boost::chrono::process_cpu_clock>, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >&, char const*, int, std::ostream&, boost::system::error_code&) (time_formatter.hpp:74)
==11617== by 0x403140: boost::chrono::basic_stopwatch_reporter<boost::chrono::stopwatch<boost::chrono::process_cpu_clock>, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::report(boost::system::error_code&) (stopwatch_reporter.hpp:152)
==11617== by 0x4031A4: boost::chrono::basic_stopwatch_reporter<boost::chrono::stopwatch<boost::chrono::process_cpu_clock>, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::~basic_stopwatch_reporter() (stopwatch_reporter.hpp:120)
==11617== by 0x403234: boost::chrono::basic_stopclock<boost::chrono::process_cpu_clock, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::~basic_stopclock() (stopclock.hpp:47)
==11617== by 0x40324C: boost::chrono::stopclock<boost::chrono::process_cpu_clock, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::~stopclock() (stopclock.hpp:116)
==11617== by 0x401741: main (Chrono.cpp:8)
==11617==
==11617== Conditional jump or move depends on uninitialised value(s)
==11617== at 0x503B0B3: boost::chrono::duration<long, boost::ratio<1l, 1000000000l> >::operator=(boost::chrono::duration<long, boost::ratio<1l, 1000000000l> > const&) (chrono.hpp:538)
==11617== by 0x503AD9B: boost::chrono::process_clock::now(boost::chrono::process_clock::durations&, boost::system::error_code&) (process_clock.cpp:60)
==11617== by 0x503D5B4: boost::chrono::process_cpu_clock::now(boost::system::error_code&) (process_cpu_clocks.cpp:43)
==11617== by 0x4028F6: boost::chrono::stopwatch<boost::chrono::process_cpu_clock>::elapsed(boost::system::error_code&) (stopwatch.hpp:156)
==11617== by 0x402A63: void boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> >::show_time<boost::chrono::basic_stopwatch_reporter<boost::chrono::stopwatch<boost::chrono::process_cpu_clock>, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > > >(boost::chrono::basic_stopwatch_reporter<boost::chrono::stopwatch<boost::chrono::process_cpu_clock>, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >&, char const*, int, std::ostream&, boost::system::error_code&) (time_formatter.hpp:74)
==11617== by 0x403140: boost::chrono::basic_stopwatch_reporter<boost::chrono::stopwatch<boost::chrono::process_cpu_clock>, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::report(boost::system::error_code&) (stopwatch_reporter.hpp:152)
==11617== by 0x4031A4: boost::chrono::basic_stopwatch_reporter<boost::chrono::stopwatch<boost::chrono::process_cpu_clock>, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::~basic_stopwatch_reporter() (stopwatch_reporter.hpp:120)
==11617== by 0x403234: boost::chrono::basic_stopclock<boost::chrono::process_cpu_clock, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::~basic_stopclock() (stopclock.hpp:47)
==11617== by 0x40324C: boost::chrono::stopclock<boost::chrono::process_cpu_clock, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::~stopclock() (stopclock.hpp:116)
==11617== by 0x401741: main (Chrono.cpp:8)
==11617==
==11617== Conditional jump or move depends on uninitialised value(s)
==11617== at 0x503B0B3: boost::chrono::duration<long, boost::ratio<1l, 1000000000l> >::operator=(boost::chrono::duration<long, boost::ratio<1l, 1000000000l> > const&) (chrono.hpp:538)
==11617== by 0x503ADFB: boost::chrono::process_clock::now(boost::chrono::process_clock::durations&, boost::system::error_code&) (process_clock.cpp:61)
==11617== by 0x503D5B4: boost::chrono::process_cpu_clock::now(boost::system::error_code&) (process_cpu_clocks.cpp:43)
==11617== by 0x4028F6: boost::chrono::stopwatch<boost::chrono::process_cpu_clock>::elapsed(boost::system::error_code&) (stopwatch.hpp:156)
==11617== by 0x402A63: void boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> >::show_time<boost::chrono::basic_stopwatch_reporter<boost::chrono::stopwatch<boost::chrono::process_cpu_clock>, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > > >(boost::chrono::basic_stopwatch_reporter<boost::chrono::stopwatch<boost::chrono::process_cpu_clock>, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >&, char const*, int, std::ostream&, boost::system::error_code&) (time_formatter.hpp:74)
==11617== by 0x403140: boost::chrono::basic_stopwatch_reporter<boost::chrono::stopwatch<boost::chrono::process_cpu_clock>, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::report(boost::system::error_code&) (stopwatch_reporter.hpp:152)
==11617== by 0x4031A4: boost::chrono::basic_stopwatch_reporter<boost::chrono::stopwatch<boost::chrono::process_cpu_clock>, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::~basic_stopwatch_reporter() (stopwatch_reporter.hpp:120)
==11617== by 0x403234: boost::chrono::basic_stopclock<boost::chrono::process_cpu_clock, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::~basic_stopclock() (stopclock.hpp:47)
==11617== by 0x40324C: boost::chrono::stopclock<boost::chrono::process_cpu_clock, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::~stopclock() (stopclock.hpp:116)
==11617== by 0x401741: main (Chrono.cpp:8)
real 0.030s, cpu 0.030s (100.0%), user 0.030s, system 0.000s
==11617==
==11617== Conditional jump or move depends on uninitialised value(s)
==11617== at 0x503B0B3: boost::chrono::duration<long, boost::ratio<1l, 1000000000l> >::operator=(boost::chrono::duration<long, boost::ratio<1l, 1000000000l> > const&) (chrono.hpp:538)
==11617== by 0x503AD3B: boost::chrono::process_clock::now(boost::chrono::process_clock::durations&, boost::system::error_code&) (process_clock.cpp:59)
==11617== by 0x503D5B4: boost::chrono::process_cpu_clock::now(boost::system::error_code&) (process_cpu_clocks.cpp:43)
==11617== by 0x4025BA: boost::chrono::stopwatch<boost::chrono::process_cpu_clock>::start(boost::system::error_code&) (stopwatch.hpp:80)
==11617== by 0x402688: boost::chrono::stopwatch<boost::chrono::process_cpu_clock>::stopwatch(boost::system::error_code&) (stopwatch.hpp:70)
==11617== by 0x4026F0: boost::chrono::basic_stopwatch_reporter<boost::chrono::stopwatch<boost::chrono::process_cpu_clock>, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::basic_stopwatch_reporter(boost::system::error_code&) (stopwatch_reporter.hpp:79)
==11617== by 0x402796: boost::chrono::basic_stopclock<boost::chrono::process_cpu_clock, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::basic_stopclock(boost::system::error_code&) (stopclock.hpp:58)
==11617== by 0x4027B6: boost::chrono::stopclock<boost::chrono::process_cpu_clock, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::stopclock(boost::system::error_code&) (stopclock.hpp:127)
==11617== by 0x401752: main (Chrono.cpp:10)
==11617==
==11617== Conditional jump or move depends on uninitialised value(s)
==11617== at 0x503B0B3: boost::chrono::duration<long, boost::ratio<1l, 1000000000l> >::operator=(boost::chrono::duration<long, boost::ratio<1l, 1000000000l> > const&) (chrono.hpp:538)
==11617== by 0x503AD9B: boost::chrono::process_clock::now(boost::chrono::process_clock::durations&, boost::system::error_code&) (process_clock.cpp:60)
==11617== by 0x503D5B4: boost::chrono::process_cpu_clock::now(boost::system::error_code&) (process_cpu_clocks.cpp:43)
==11617== by 0x4025BA: boost::chrono::stopwatch<boost::chrono::process_cpu_clock>::start(boost::system::error_code&) (stopwatch.hpp:80)
==11617== by 0x402688: boost::chrono::stopwatch<boost::chrono::process_cpu_clock>::stopwatch(boost::system::error_code&) (stopwatch.hpp:70)
==11617== by 0x4026F0: boost::chrono::basic_stopwatch_reporter<boost::chrono::stopwatch<boost::chrono::process_cpu_clock>, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::basic_stopwatch_reporter(boost::system::error_code&) (stopwatch_reporter.hpp:79)
==11617== by 0x402796: boost::chrono::basic_stopclock<boost::chrono::process_cpu_clock, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::basic_stopclock(boost::system::error_code&) (stopclock.hpp:58)
==11617== by 0x4027B6: boost::chrono::stopclock<boost::chrono::process_cpu_clock, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::stopclock(boost::system::error_code&) (stopclock.hpp:127)
==11617== by 0x401752: main (Chrono.cpp:10)
==11617==
==11617== Conditional jump or move depends on uninitialised value(s)
==11617== at 0x503B0B3: boost::chrono::duration<long, boost::ratio<1l, 1000000000l> >::operator=(boost::chrono::duration<long, boost::ratio<1l, 1000000000l> > const&) (chrono.hpp:538)
==11617== by 0x503ADFB: boost::chrono::process_clock::now(boost::chrono::process_clock::durations&, boost::system::error_code&) (process_clock.cpp:61)
==11617== by 0x503D5B4: boost::chrono::process_cpu_clock::now(boost::system::error_code&) (process_cpu_clocks.cpp:43)
==11617== by 0x4025BA: boost::chrono::stopwatch<boost::chrono::process_cpu_clock>::start(boost::system::error_code&) (stopwatch.hpp:80)
==11617== by 0x402688: boost::chrono::stopwatch<boost::chrono::process_cpu_clock>::stopwatch(boost::system::error_code&) (stopwatch.hpp:70)
==11617== by 0x4026F0: boost::chrono::basic_stopwatch_reporter<boost::chrono::stopwatch<boost::chrono::process_cpu_clock>, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::basic_stopwatch_reporter(boost::system::error_code&) (stopwatch_reporter.hpp:79)
==11617== by 0x402796: boost::chrono::basic_stopclock<boost::chrono::process_cpu_clock, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::basic_stopclock(boost::system::error_code&) (stopclock.hpp:58)
==11617== by 0x4027B6: boost::chrono::stopclock<boost::chrono::process_cpu_clock, boost::chrono::basic_time_formatter<char, std::char_traits<char>, std::allocator<char> > >::stopclock(boost::system::error_code&) (stopclock.hpp:127)
==11617== by 0x401752: main (Chrono.cpp:10)
real 0.010s, cpu 0.010s (100.0%), user 0.010s, system 0.000s
int main()real 0.000s, cpu 0.000s (0.0%), user 0.000s, system 0.000s
==11617==
==11617== ERROR SUMMARY: 21 errors from 6 contexts (suppressed: 8 from 1)
==11617== malloc/free: in use at exit: 0 bytes in 0 blocks.
==11617== malloc/free: 4 allocs, 4 frees, 248 bytes allocated.
==11617== For counts of detected errors, rerun with: -v
==11617== All heap blocks were freed -- no leaks are possible.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk