Hey Saúl,
thanks for your update.
I now tried to use 0.10.26 (Stable) where the MAKE_VALGRIND_HAPPY looks
like this:
#define MAKE_VALGRIND_HAPPY() \
>
> do { \
>
> close_loop(uv_default_loop()); \
>
> uv_loop_delete(uv_default_loop()); \
>
> } while (0)
>
>
>> /* Fully close a loop */
>
> static void close_walk_cb(uv_handle_t* handle, void* arg) {
>
> if (!uv_is_closing(handle))
>
> uv_close(handle, NULL);
>
> }
>
>
>> static void close_loop(uv_loop_t* loop) {
>
> uv_walk(loop, close_walk_cb, NULL);
>
> uv_run(loop, UV_RUN_DEFAULT);
>
> }
>
>
When I then run the tests I get the following responses from valgrind. The
tests then segfault at the end:
==18037== Invalid read of size 1
>
> ==18037== at 0x428E3C: uv_walk (uv-common.c:317)
>
> ==18037== by 0x409CA6: close_loop(uv_loop_s*) (test_helper.h:16)
>
> ==18037== by 0x40BA82:
>> ServerConnectionTest_MultipleRequests_Test::TestBody() (server_test.cc:121)
>
> ==18037== by 0x494FC2: void
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test,
>> void>(testing::Test*, void (testing::Test::*)(), char const*)
>> (gtest.cc:2078)
>
> ==18037== by 0x47D6A6: void
>> testing::internal::HandleExceptionsInMethodIfSupported<testing::Test,
>> void>(testing::Test*, void (testing::Test::*)(), char const*)
>> (gtest.cc:2114)
>
> ==18037== by 0x449B26: testing::Test::Run() (gtest.cc:2150)
>
> ==18037== by 0x44AEFB: testing::TestInfo::Run() (gtest.cc:2326)
>
> ==18037== by 0x44BAE4: testing::TestCase::Run() (gtest.cc:2444)
>
> ==18037== by 0x45A3C4: testing::internal::UnitTestImpl::RunAllTests()
>> (gtest.cc:4315)
>
> ==18037== by 0x492112: bool
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
>>
>> bool>(testing::internal::UnitTestImpl*, bool
>> (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2078)
>
> ==18037== by 0x480796: bool
>> testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
>>
>> bool>(testing::internal::UnitTestImpl*, bool
>> (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2114)
>
> ==18037== by 0x459FB4: testing::UnitTest::Run() (gtest.cc:3926)
>
> ==18037== Address 0x619e1c9 is 9 bytes inside a block of size 96 free'd
>
> ==18037== at 0x4C2999C: free (in
>> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>
> ==18037== by 0x417950: 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)
>
> ==18037== by 0x4169E5: std::__1::basic_string<char,
>> std::__1::char_traits<char>, std::__1::allocator<char> >::push_back(char)
>> (string:2453)
>
> ==18037== by 0x4160B2: std::__1::basic_stringbuf<char,
>> std::__1::char_traits<char>, std::__1::allocator<char> >::overflow(int)
>> (sstream:528)
>
> ==18037== by 0x415EFC: std::__1::basic_streambuf<char,
>> std::__1::char_traits<char> >::xsputn(char const*, long) (streambuf:543)
>
> ==18037== by 0x41C502: 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)
>
> ==18037== by 0x4127F1: 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)
>
> ==18037== by 0x4265C7: ServerResponseBuffer::build(int)
>> (server_response_buffer.cc:20)
>
> ==18037== by 0x421382: Server::Server(int) (server.cc:8)
>
> ==18037== by 0x40B076:
>> ServerConnectionTest_MultipleRequests_Test::TestBody() (server_test.cc:101)
>
> ==18037== by 0x494FC2: void
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test,
>> void>(testing::Test*, void (testing::Test::*)(), char const*)
>> (gtest.cc:2078)
>
> ==18037== by 0x47D6A6: void
>> testing::internal::HandleExceptionsInMethodIfSupported<testing::Test,
>> void>(testing::Test*, void (testing::Test::*)(), char const*)
>> (gtest.cc:2114)
>
> ==18037==
>
> ==18037== Invalid read of size 8
>
> ==18037== at 0x42908C: uv_close (core.c:166)
>
> ==18037== by 0x411CE6: close_walk_cb(uv_handle_s*, void*)
>> (test_helper.h:12)
>
> ==18037== by 0x428E47: uv_walk (uv-common.c:318)
>
> ==18037== by 0x409CA6: close_loop(uv_loop_s*) (test_helper.h:16)
>
> ==18037== by 0x40BA82:
>> ServerConnectionTest_MultipleRequests_Test::TestBody() (server_test.cc:121)
>
> ==18037== by 0x494FC2: void
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test,
>> void>(testing::Test*, void (testing::Test::*)(), char const*)
>> (gtest.cc:2078)
>
> ==18037== by 0x47D6A6: void
>> testing::internal::HandleExceptionsInMethodIfSupported<testing::Test,
>> void>(testing::Test*, void (testing::Test::*)(), char const*)
>> (gtest.cc:2114)
>
> ==18037== by 0x449B26: testing::Test::Run() (gtest.cc:2150)
>
> ==18037== by 0x44AEFB: testing::TestInfo::Run() (gtest.cc:2326)
>
> ==18037== by 0x44BAE4: testing::TestCase::Run() (gtest.cc:2444)
>
> ==18037== by 0x45A3C4: testing::internal::UnitTestImpl::RunAllTests()
>> (gtest.cc:4315)
>
> ==18037== by 0x492112: bool
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
>>
>> bool>(testing::internal::UnitTestImpl*, bool
>> (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2078)
>
> ==18037== Address 0x308 is not stack'd, malloc'd or (recently) free'd
>
> ==18037==
>
> ==18037==
>
> ==18037== Process terminating with default action of signal 11 (SIGSEGV)
>
> ==18037== Access not within mapped region at address 0x308
>
> ==18037== at 0x42908C: uv_close (core.c:166)
>
> ==18037== by 0x411CE6: close_walk_cb(uv_handle_s*, void*)
>> (test_helper.h:12)
>
> ==18037== by 0x428E47: uv_walk (uv-common.c:318)
>
> ==18037== by 0x409CA6: close_loop(uv_loop_s*) (test_helper.h:16)
>
> ==18037== by 0x40BA82:
>> ServerConnectionTest_MultipleRequests_Test::TestBody() (server_test.cc:121)
>
> ==18037== by 0x494FC2: void
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test,
>> void>(testing::Test*, void (testing::Test::*)(), char const*)
>> (gtest.cc:2078)
>
> ==18037== by 0x47D6A6: void
>> testing::internal::HandleExceptionsInMethodIfSupported<testing::Test,
>> void>(testing::Test*, void (testing::Test::*)(), char const*)
>> (gtest.cc:2114)
>
> ==18037== by 0x449B26: testing::Test::Run() (gtest.cc:2150)
>
> ==18037== by 0x44AEFB: testing::TestInfo::Run() (gtest.cc:2326)
>
> ==18037== by 0x44BAE4: testing::TestCase::Run() (gtest.cc:2444)
>
> ==18037== by 0x45A3C4: testing::internal::UnitTestImpl::RunAllTests()
>> (gtest.cc:4315)
>
> ==18037== by 0x492112: bool
>> testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
>>
>> bool>(testing::internal::UnitTestImpl*, bool
>> (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2078)
>
> ==18037== If you believe this happened as a result of a stack
>
> ==18037== overflow in your program's main thread (unlikely but
>
> ==18037== possible), you can try to increase the size of the
>
> ==18037== main thread stack using the --main-stacksize= flag.
>
> ==18037== The main thread stack size used in this run was 8388608.
>
> ==18037== 8 bytes in 1 blocks are still reachable in loss record 1 of 58
>
> ==18037== at 0x4C28730: malloc (in
>> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>
> ==18037== by 0x4062E09: operator new(unsigned long) (in
>> /usr/lib/libc++abi.so.1.0)
>
> ==18037== by 0x407F5C: __cxx_global_var_init (server_test.cc:7)
>
> ==18037== by 0x408848: global constructors keyed to a
>> (server_test.cc:365)
>
> ==18037== by 0x4A08AC: __libc_csu_init (in
>> /root/phd-projects/02_scales_journal/wsf/test/server_test)
>
> ==18037== by 0x5588A94: (below main) (in /usr/lib/libc-2.19.so)
>
> ==18037==
>
>
Is the last stable version (0.10.26) the right one to use? Do you think the
issue is due to shutting down the event loop?
Thank you very much for your help,
Tommy
On Tuesday, April 29, 2014 11:27:23 PM UTC+1, Saúl Ibarra Corretgé wrote:
>
> Hi,
>
> On 4/29/14 12:43 PM, Thomas Fankhauser wrote:
> > 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:
> >
>
> You need to leave MAKE_VALGRIND_HAPPY, so that the loop is closed and
> all resources are freed after each run.
>
> [snip]
>
> >
> > 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!
> >
>
> I don't really know how to try to figure this out, but using latest
> master would give matching line numbers so I can try to see if there is
> something wrong. Also the code in uv_loop_delete changed quite a bit.
> Not that it will fix this, though.
>
>
> Cheers,
>
> --
> Saúl Ibarra Corretgé
> http://bettercallsaghul.com
>
--
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.