Hey there,

we are using UV in a C++ project tested with GoogleTest and want to use 
valgrind.

If we run each test individually - via the gtest_filter using valgrind, all 
tests run just fine and leak no memory.
But if we want to run the whole suite we get various valgrind complains, 
although the tests finish successfully.

Without using MAKE_VALGRIND_HAPPY() at the end of the test, the complains 
look like this:

==14376== Invalid write of size 8
>
> ==14376==    at 0x42D299: uv__stream_init (stream.c:113)
>
> ==14376==    by 0x42E8CD: uv_tcp_init (tcp.c:32)
>
> ==14376==    by 0x421377: Server::start() (server.cc:22)
>
> ==14376==    by 0x40AFB4: 
>> ServerConnectionTest_MultipleRequests_Test::TestBody() (server_test.cc:98)
>
> ==14376==    by 0x4944D2: void 
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, 
>> void>(testing::Test*, void (testing::Test::*)(), char const*) 
>> (gtest.cc:2078)
>
> ==14376==    by 0x47CBB6: void 
>> testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, 
>> void>(testing::Test*, void (testing::Test::*)(), char const*) 
>> (gtest.cc:2114)
>
> ==14376==    by 0x449036: testing::Test::Run() (gtest.cc:2150)
>
> ==14376==    by 0x44A40B: testing::TestInfo::Run() (gtest.cc:2326)
>
> ==14376==    by 0x44AFF4: testing::TestCase::Run() (gtest.cc:2444)
>
> ==14376==    by 0x4598D4: testing::internal::UnitTestImpl::RunAllTests() 
>> (gtest.cc:4315)
>
> ==14376==    by 0x491622: bool 
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
>>  
>> bool>(testing::internal::UnitTestImpl*, bool 
>> (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2078)
>
> ==14376==    by 0x47FCA6: bool 
>> testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
>>  
>> bool>(testing::internal::UnitTestImpl*, bool 
>> (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2114)
>
> ==14376==  Address 0x619e1b0 is 16 bytes before a block of size 96 free'd
>
> ==14376==    at 0x4C2999C: free (in 
>> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>
> ==14376==    by 0x4175E0: std::__1::basic_string<char, 
>> std::__1::char_traits<char>, std::__1::allocator<char> 
>> >::__grow_by(unsigned long, unsigned long, unsigned long, unsigned long, 
>> unsigned long, unsigned long) (memory:1632)
>
> ==14376==    by 0x416675: std::__1::basic_string<char, 
>> std::__1::char_traits<char>, std::__1::allocator<char> >::push_back(char) 
>> (string:2453)
>
> ==14376==    by 0x415D42: std::__1::basic_stringbuf<char, 
>> std::__1::char_traits<char>, std::__1::allocator<char> >::overflow(int) 
>> (sstream:528)
>
> ==14376==    by 0x415B8C: std::__1::basic_streambuf<char, 
>> std::__1::char_traits<char> >::xsputn(char const*, long) (streambuf:543)
>
> ==14376==    by 0x41C192: std::__1::ostreambuf_iterator<char, 
>> std::__1::char_traits<char> > std::__1::__pad_and_output<char, 
>> std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, 
>> std::__1::char_traits<char> >, char const*, char const*, char const*, 
>> std::__1::ios_base&, char) (streambuf:360)
>
> ==14376==    by 0x412491: std::__1::basic_ostream<char, 
>> std::__1::char_traits<char> >& std::__1::operator<< <char, 
>> std::__1::char_traits<char>, std::__1::allocator<char> 
>> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, 
>> std::__1::basic_string<char, std::__1::char_traits<char>, 
>> std::__1::allocator<char> > const&) (ostream:1245)
>
> ==14376==    by 0x426277: ServerResponseBuffer::build(int) 
>> (server_response_buffer.cc:20)
>
> ==14376==    by 0x421006: Server::Server(int) (server.cc:8)
>
> ==14376==    by 0x40AEA6: 
>> ServerConnectionTest_MultipleRequests_Test::TestBody() (server_test.cc:95)
>
> ==14376==    by 0x4944D2: void 
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, 
>> void>(testing::Test*, void (testing::Test::*)(), char const*) 
>> (gtest.cc:2078)
>
> ==14376==    by 0x47CBB6: void 
>> testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, 
>> void>(testing::Test*, void (testing::Test::*)(), char const*) 
>> (gtest.cc:2114)
>
> ==14376==
>
> ==14376== Invalid write of size 8
>
> ==14376==    at 0x428E01: uv_run (core.c:201)
>
> ==14376==    by 0x42235D: Server::run() (server.cc:36)
>
> ==14376==    by 0x40B88B: 
>> ServerConnectionTest_MultipleRequests_Test::TestBody() (server_test.cc:113)
>
> ==14376==    by 0x4944D2: void 
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, 
>> void>(testing::Test*, void (testing::Test::*)(), char const*) 
>> (gtest.cc:2078)
>
> ==14376==    by 0x47CBB6: void 
>> testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, 
>> void>(testing::Test*, void (testing::Test::*)(), char const*) 
>> (gtest.cc:2114)
>
> ==14376==    by 0x449036: testing::Test::Run() (gtest.cc:2150)
>
> ==14376==    by 0x44A40B: testing::TestInfo::Run() (gtest.cc:2326)
>
> ==14376==    by 0x44AFF4: testing::TestCase::Run() (gtest.cc:2444)
>
> ==14376==    by 0x4598D4: testing::internal::UnitTestImpl::RunAllTests() 
>> (gtest.cc:4315)
>
> ==14376==    by 0x491622: bool 
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
>>  
>> bool>(testing::internal::UnitTestImpl*, bool 
>> (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2078)
>
> ==14376==    by 0x47FCA6: bool 
>> testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
>>  
>> bool>(testing::internal::UnitTestImpl*, bool 
>> (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2114)
>
> ==14376==    by 0x4594C4: testing::UnitTest::Run() (gtest.cc:3926)
>
> ==14376==  Address 0x619e1b0 is 16 bytes before a block of size 96 free'd
>
> ==14376==    at 0x4C2999C: free (in 
>> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>
> ==14376==    by 0x4175E0: std::__1::basic_string<char, 
>> std::__1::char_traits<char>, std::__1::allocator<char> 
>> >::__grow_by(unsigned long, unsigned long, unsigned long, unsigned long, 
>> unsigned long, unsigned long) (memory:1632)
>
> ==14376==    by 0x416675: std::__1::basic_string<char, 
>> std::__1::char_traits<char>, std::__1::allocator<char> >::push_back(char) 
>> (string:2453)
>
> ==14376==    by 0x415D42: std::__1::basic_stringbuf<char, 
>> std::__1::char_traits<char>, std::__1::allocator<char> >::overflow(int) 
>> (sstream:528)
>
> ==14376==    by 0x415B8C: std::__1::basic_streambuf<char, 
>> std::__1::char_traits<char> >::xsputn(char const*, long) (streambuf:543)
>
> ==14376==    by 0x41C192: std::__1::ostreambuf_iterator<char, 
>> std::__1::char_traits<char> > std::__1::__pad_and_output<char, 
>> std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, 
>> std::__1::char_traits<char> >, char const*, char const*, char const*, 
>> std::__1::ios_base&, char) (streambuf:360)
>
> ==14376==    by 0x412491: std::__1::basic_ostream<char, 
>> std::__1::char_traits<char> >& std::__1::operator<< <char, 
>> std::__1::char_traits<char>, std::__1::allocator<char> 
>> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, 
>> std::__1::basic_string<char, std::__1::char_traits<char>, 
>> std::__1::allocator<char> > const&) (ostream:1245)
>
> ==14376==    by 0x426277: ServerResponseBuffer::build(int) 
>> (server_response_buffer.cc:20)
>
> ==14376==    by 0x421006: Server::Server(int) (server.cc:8)
>
> ==14376==    by 0x40AEA6: 
>> ServerConnectionTest_MultipleRequests_Test::TestBody() (server_test.cc:95)
>
> ==14376==    by 0x4944D2: void 
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, 
>> void>(testing::Test*, void (testing::Test::*)(), char const*) 
>> (gtest.cc:2078)
>
> ==14376==    by 0x47CBB6: void 
>> testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, 
>> void>(testing::Test*, void (testing::Test::*)(), char const*) 
>> (gtest.cc:2114)
>
> ==14376==
>
>
If we use MAKE_VALGRIND_HAPPY() we get the following complains:

==14400== Invalid read of size 4
>
> ==14400==    at 0x42BF48: uv__signal_loop_cleanup (signal.c:241)
>
> ==14400==    by 0x429EFD: uv_loop_delete (loop.c:134)
>
> ==14400==    by 0x40AE52: 
>> ServerConnectionTest_SingleRequest_Test::TestBody() (server_test.cc:96)
>
> ==14400==    by 0x494592: void 
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, 
>> void>(testing::Test*, void (testing::Test::*)(), char const*) 
>> (gtest.cc:2078)
>
> ==14400==    by 0x47CC76: void 
>> testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, 
>> void>(testing::Test*, void (testing::Test::*)(), char const*) 
>> (gtest.cc:2114)
>
> ==14400==    by 0x4490F6: testing::Test::Run() (gtest.cc:2150)
>
> ==14400==    by 0x44A4CB: testing::TestInfo::Run() (gtest.cc:2326)
>
> ==14400==    by 0x44B0B4: testing::TestCase::Run() (gtest.cc:2444)
>
> ==14400==    by 0x459994: testing::internal::UnitTestImpl::RunAllTests() 
>> (gtest.cc:4315)
>
> ==14400==    by 0x4916E2: bool 
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
>>  
>> bool>(testing::internal::UnitTestImpl*, bool 
>> (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2078)
>
> ==14400==    by 0x47FD66: bool 
>> testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
>>  
>> bool>(testing::internal::UnitTestImpl*, bool 
>> (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2114)
>
> ==14400==    by 0x459584: testing::UnitTest::Run() (gtest.cc:3926)
>
> ==14400==  Address 0x5d8b828 is 424 bytes inside a block of size 624 free'd
>
> ==14400==    at 0x4C2999C: free (in 
>> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>
> ==14400==    by 0x424C9D: ServerConnection::onClose(uv_handle_s*) 
>> (server_connection.cc:51)
>
> ==14400==    by 0x424C44: ServerConnection::thisOnClose(uv_handle_s*) 
>> (server_connection.cc:145)
>
> ==14400==    by 0x428EDC: uv_run (core.c:204)
>
> ==14400==    by 0x42241D: Server::run() (server.cc:36)
>
> ==14400==    by 0x40AE30: 
>> ServerConnectionTest_SingleRequest_Test::TestBody() (server_test.cc:94)
>
> ==14400==    by 0x494592: void 
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, 
>> void>(testing::Test*, void (testing::Test::*)(), char const*) 
>> (gtest.cc:2078)
>
> ==14400==    by 0x47CC76: void 
>> testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, 
>> void>(testing::Test*, void (testing::Test::*)(), char const*) 
>> (gtest.cc:2114)
>
> ==14400==    by 0x4490F6: testing::Test::Run() (gtest.cc:2150)
>
> ==14400==    by 0x44A4CB: testing::TestInfo::Run() (gtest.cc:2326)
>
> ==14400==    by 0x44B0B4: testing::TestCase::Run() (gtest.cc:2444)
>
> ==14400==    by 0x459994: testing::internal::UnitTestImpl::RunAllTests() 
>> (gtest.cc:4315)
>
> ==14400==
>
> ==14400== Invalid read of size 8
>
> ==14400==    at 0x42BF40: uv__signal_loop_cleanup (signal.c:238)
>
> ==14400==    by 0x429EFD: uv_loop_delete (loop.c:134)
>
> ==14400==    by 0x40AE52: 
>> ServerConnectionTest_SingleRequest_Test::TestBody() (server_test.cc:96)
>
> ==14400==    by 0x494592: void 
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, 
>> void>(testing::Test*, void (testing::Test::*)(), char const*) 
>> (gtest.cc:2078)
>
> ==14400==    by 0x47CC76: void 
>> testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, 
>> void>(testing::Test*, void (testing::Test::*)(), char const*) 
>> (gtest.cc:2114)
>
> ==14400==    by 0x4490F6: testing::Test::Run() (gtest.cc:2150)
>
> ==14400==    by 0x44A4CB: testing::TestInfo::Run() (gtest.cc:2326)
>
> ==14400==    by 0x44B0B4: testing::TestCase::Run() (gtest.cc:2444)
>
> ==14400==    by 0x459994: testing::internal::UnitTestImpl::RunAllTests() 
>> (gtest.cc:4315)
>
> ==14400==    by 0x4916E2: bool 
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
>>  
>> bool>(testing::internal::UnitTestImpl*, bool 
>> (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2078)
>
> ==14400==    by 0x47FD66: bool 
>> testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
>>  
>> bool>(testing::internal::UnitTestImpl*, bool 
>> (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2114)
>
> ==14400==    by 0x459584: testing::UnitTest::Run() (gtest.cc:3926)
>
> ==14400==  Address 0x5d8b830 is 432 bytes inside a block of size 624 free'd
>
> ==14400==    at 0x4C2999C: free (in 
>> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>
> ==14400==    by 0x424C9D: ServerConnection::onClose(uv_handle_s*) 
>> (server_connection.cc:51)
>
> ==14400==    by 0x424C44: ServerConnection::thisOnClose(uv_handle_s*) 
>> (server_connection.cc:145)
>
> ==14400==    by 0x428EDC: uv_run (core.c:204)
>
> ==14400==    by 0x42241D: Server::run() (server.cc:36)
>
> ==14400==    by 0x40AE30: 
>> ServerConnectionTest_SingleRequest_Test::TestBody() (server_test.cc:94)
>
> ==14400==    by 0x494592: void 
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, 
>> void>(testing::Test*, void (testing::Test::*)(), char const*) 
>> (gtest.cc:2078)
>
> ==14400==    by 0x47CC76: void 
>> testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, 
>> void>(testing::Test*, void (testing::Test::*)(), char const*) 
>> (gtest.cc:2114)
>
> ==14400==    by 0x4490F6: testing::Test::Run() (gtest.cc:2150)
>
> ==14400==    by 0x44A4CB: testing::TestInfo::Run() (gtest.cc:2326)
>
> ==14400==    by 0x44B0B4: testing::TestCase::Run() (gtest.cc:2444)
>
> ==14400==    by 0x459994: testing::internal::UnitTestImpl::RunAllTests() 
>> (gtest.cc:4315)
>
> ==14400==
>
>
The issues occur on both OSX 10.9 and Arch64 with both the gcc version 
4.8.2 and clang version 3.4 build chain.
We are using UV 2014.01.30, Version 0.11.19 and GoogleTest 1.7.0.

There are some comments in the test headers regarding valgrind - if we got 
that right valgrind is used as usual with the command line 
options --leak-check=full --quiet.

We also tried debugging the invalid read, but couldn't find out more.

Do you have any idea where this errors could come from? We assume its 
somewhere along the test shutdown, but how can we fix that?

Thank you for your help, our heads are melting here!

Best regards and thanks for any clues,
Tommy


-- 
You received this message because you are subscribed to the Google Groups 
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.

Reply via email to