Subject: Re: arestest segfaults for me

Re: arestest segfaults for me

From: David Drysdale via c-ares <c-ares_at_cool.haxx.se>
Date: Fri, 23 Sep 2016 09:30:48 +0100

On Fri, Sep 23, 2016 at 8:25 AM, Daniel Stenberg <daniel_at_haxx.se> wrote:

> Hey,
>
> As I'm currently fiddling with some c-ares functions I figured I should
> get the tests running properly to allow me to verify my pending changes.
>
> I built c-ares with the tests enabled, only to figure out that 'make test'
> ends up in a segfault with the current git master!
>

Is that just with valgrind, or are there problems with a normal run too?

(The continuous builds were fine at commit a5b2e99207fd12 (
https://travis-ci.org/c-ares/c-ares/builds/153926206), but they use ASAN
for memory checking rather than valgrind.)

> If I manually setup my LD_LIBRARY_PATH and invoke "valgrind
> ./.libs/arestest" from within the test dir, this is what I get. The entire
> call stack seems to be in the test infra and not c-ares itself, but it's
> not immediately obvious to me what the problem is as I'm really not
> familiar with this framework.
>
> [----------] 112 tests from AddressFamilies/MockChannelTest
> [ RUN ] AddressFamilies/MockChannelTest.Basic/0
> ==24391== Invalid read of size 8
> ==24391== at 0x4169E6: GetValueAndDelete (gmock-spec-builders.h:1373)
> ==24391== by 0x4169E6: InvokeWith (gmock-spec-builders.h:1530)
> ==24391== by 0x4169E6: Invoke (gmock-generated-function-mockers.h:118)
> ==24391== by 0x4169E6: OnRequest (ares-test.h:133)
> ==24391== by 0x4169E6: ares::test::MockServer::ProcessRequest(int,
> sockaddr_storage*, int, int, std::__cxx11::basic_string<char,
> std::char_traits<char>, std::allocator<char> > const&, int)
> (ares-test.cc:319)
> ==24391== by 0x41736C: ares::test::MockServer::ProcessFD(int)
> (ares-test.cc:306)
> ==24391== by 0x41747A: ares::test::MockChannelOptsTest::ProcessFD(int)
> (ares-test.cc:471)
> ==24391== by 0x416482: operator() (functional:2136)
> ==24391== by 0x416482: ares::test::ProcessWork(ares_channeldata*,
> std::function<std::set<int, std::less<int>, std::allocator<int> > ()>,
> std::function<void (int)>) (ares-test.cc:77)
> ==24391== by 0x416701: ares::test::MockChannelOptsTest::Process()
> (ares-test.cc:479)
> ==24391== by 0x4A30B9: ares::test::MockChannelTest_Basic_Test::TestBody()
> (ares-test-mock.cc:46)
> ==24391== by 0x515133: HandleSehExceptionsInMethodIfSupported<testing::Test,
> void> (gtest.cc:2078)
> ==24391== by 0x515133: void testing::internal::HandleExcep
> tionsInMethodIfSupported<testing::Test, void>(testing::Test*, void
> (testing::Test::*)(), char const*) (gtest.cc:2114)
> ==24391== by 0x50DEC9: testing::Test::Run() (gtest.cc:2151)
> ==24391== by 0x50E017: testing::TestInfo::Run() (gtest.cc:2326)
> ==24391== by 0x50E0F4: testing::TestCase::Run() (gtest.cc:2444)
> ==24391== by 0x50E3A6: testing::internal::UnitTestImpl::RunAllTests()
> (gtest.cc:4315)
> ==24391== by 0x515583: HandleSehExceptionsInMethodIfS
> upported<testing::internal::UnitTestImpl, bool> (gtest.cc:2078)
> ==24391== by 0x515583: bool testing::internal::HandleExcep
> tionsInMethodIfSupported<testing::internal::UnitTestImpl,
> bool>(testing::internal::UnitTestImpl*, bool
> (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2114)
> ==24391== Address 0x0 is not stack'd, malloc'd or (recently) free'd
> ==24391==
> ==24391==
> ==24391== Process terminating with default action of signal 11 (SIGSEGV)
> ==24391== Access not within mapped region at address 0x0
> ==24391== at 0x4169E6: GetValueAndDelete (gmock-spec-builders.h:1373)
> ==24391== by 0x4169E6: InvokeWith (gmock-spec-builders.h:1530)
> ==24391== by 0x4169E6: Invoke (gmock-generated-function-mockers.h:118)
> ==24391== by 0x4169E6: OnRequest (ares-test.h:133)
> ==24391== by 0x4169E6: ares::test::MockServer::ProcessRequest(int,
> sockaddr_storage*, int, int, std::__cxx11::basic_string<char,
> std::char_traits<char>, std::allocator<char> > const&, int)
> (ares-test.cc:319)
> ==24391== by 0x41736C: ares::test::MockServer::ProcessFD(int)
> (ares-test.cc:306)
> ==24391== by 0x41747A: ares::test::MockChannelOptsTest::ProcessFD(int)
> (ares-test.cc:471)
> ==24391== by 0x416482: operator() (functional:2136)
> ==24391== by 0x416482: ares::test::ProcessWork(ares_channeldata*,
> std::function<std::set<int, std::less<int>, std::allocator<int> > ()>,
> std::function<void (int)>) (ares-test.cc:77)
> ==24391== by 0x416701: ares::test::MockChannelOptsTest::Process()
> (ares-test.cc:479)
> ==24391== by 0x4A30B9: ares::test::MockChannelTest_Basic_Test::TestBody()
> (ares-test-mock.cc:46)
> ==24391== by 0x515133: HandleSehExceptionsInMethodIfSupported<testing::Test,
> void> (gtest.cc:2078)
> ==24391== by 0x515133: void testing::internal::HandleExcep
> tionsInMethodIfSupported<testing::Test, void>(testing::Test*, void
> (testing::Test::*)(), char const*) (gtest.cc:2114)
> ==24391== by 0x50DEC9: testing::Test::Run() (gtest.cc:2151)
> ==24391== by 0x50E017: testing::TestInfo::Run() (gtest.cc:2326)
> ==24391== by 0x50E0F4: testing::TestCase::Run() (gtest.cc:2444)
> ==24391== by 0x50E3A6: testing::internal::UnitTestImpl::RunAllTests()
> (gtest.cc:4315)
> ==24391== by 0x515583: HandleSehExceptionsInMethodIfS
> upported<testing::internal::UnitTestImpl, bool> (gtest.cc:2078)
> ==24391== by 0x515583: bool testing::internal::HandleExcep
> tionsInMethodIfSupported<testing::internal::UnitTestImpl,
> bool>(testing::internal::UnitTestImpl*, bool
> (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2114)
> ==24391== If you believe this happened as a result of a stack
> ==24391== overflow in your program's main thread (unlikely but
> ==24391== possible), you can try to increase the size of the
> ==24391== main thread stack using the --main-stacksize= flag.
> ==24391== The main thread stack size used in this run was 8388608.
> ==24391==
> ==24391== HEAP SUMMARY:
> ==24391== in use at exit: 198,919 bytes in 1,721 blocks
> ==24391== total heap usage: 22,025 allocs, 20,304 frees, 13,527,325
> bytes allocated
> ==24391==
> ==24391== LEAK SUMMARY:
> ==24391== definitely lost: 0 bytes in 0 blocks
> ==24391== indirectly lost: 0 bytes in 0 blocks
> ==24391== possibly lost: 330 bytes in 6 blocks
> ==24391== still reachable: 198,589 bytes in 1,715 blocks
> ==24391== suppressed: 0 bytes in 0 blocks
> ==24391== Rerun with --leak-check=full to see details of leaked memory
> ==24391==
> ==24391== For counts of detected and suppressed errors, rerun with: -v
> ==24391== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
> Segmentation fault
>
>
> --
>
> / daniel.haxx.se
>
Received on 2016-09-23