Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault on null pointer when running tests built with Release or RelWithDebInfo build types #478

Closed
keith-bennett-gbg opened this issue Mar 20, 2017 · 2 comments

Comments

@keith-bennett-gbg
Copy link

keith-bennett-gbg commented Mar 20, 2017

Note that, to debug this, I added fsanitize=address -fno-omit-frame-pointer to compiler and linker flags for the compiled targets. Gist of a diff you can apply: https://gist.github.com/keith-bennett-gbg/6ea43597acd55b2f338f34893f54401b#file-yaml-cpp-address-sanitizer-diff

$ git clone "https://github.com/jbeder/yaml-cpp.git"
$ cd yaml-cpp
$ cp "${HOME}/yaml-cpp.address-sanitizer.diff" ./
$ git checkout 0fdb1b910c1a31db80b7521446166d06cad10813 # HEAD as of creation of this issue.
$ git apply yaml-cpp.address-sanitizer.diff
$ mkdir build && cd build
$ cmake -DCMAKE_BUILD_TYPE="RelWithDebInfo" ../ && make -j$(nproc) && make test
-- The C compiler identification is GNU 6.2.0
-- The CXX compiler identification is GNU 6.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test FLAG_WEXTRA
-- Performing Test FLAG_WEXTRA - Success
-- Found PythonInterp: /usr/bin/python (found version "2.7.12") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/keithb/dev/yaml-cpp/build

cmake is successful...
build is successful...
running tests...

Running tests...
Test project /home/keithb/dev/yaml-cpp-second/build
    Start 1: yaml-test
1/1 Test #1: yaml-test ........................***Failed    0.50 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.50 sec

The following tests FAILED:
	  1 - yaml-test (Failed)
Errors while running CTest
Makefile:94: recipe for target 'test' failed
make: *** [test] Error 8

Tests failed. Running them manually discovers:

$ ./test/run-tests
...
[----------] 10 tests from EncodingTest
[ RUN      ] EncodingTest.UTF8_noBOM
ASAN:DEADLYSIGNAL
=================================================================
==15648==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00000048ffe1 bp 0x7fff8cce17d0 sp 0x7fff8cce17b0 T0)
    #0 0x48ffe0 in testing::internal::ActionResultHolder<void>::GetValueAndDelete() const /home/keithb/dev/yaml-cpp/test/gmock-1.7.0/include/gmock/gmock-spec-builders.h:1373
    #1 0x48ffe0 in testing::internal::FunctionMockerBase<void (YAML::Mark const&)>::InvokeWith(std::tuple<YAML::Mark const&> const&) /home/keithb/dev/yaml-cpp/test/gmock-1.7.0/include/gmock/gmock-spec-builders.h:1530
    #2 0x48ffe0 in testing::internal::FunctionMocker<void (YAML::Mark const&)>::Invoke(YAML::Mark const&) /home/keithb/dev/yaml-cpp/test/gmock-1.7.0/include/gmock/gmock-generated-function-mockers.h:97
    #3 0x48ffe0 in YAML::MockEventHandler::OnDocumentStart(YAML::Mark const&) /home/keithb/dev/yaml-cpp/test/mock_event_handler.h:10
    #4 0x800ebc in YAML::SingleDocParser::HandleDocument(YAML::EventHandler&) /home/keithb/dev/yaml-cpp/src/singledocparser.cpp:32
    #5 0x7c2d77 in YAML::Parser::HandleNextDocument(YAML::EventHandler&) /home/keithb/dev/yaml-cpp/src/parser.cpp:39
    #6 0x48e4b6 in YAML::HandlerTest::Parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/keithb/dev/yaml-cpp/test/handler_test.h:17
    #7 0x48e4b6 in Run /home/keithb/dev/yaml-cpp/test/integration/encoding_test.cpp:105
    #8 0x852223 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/keithb/dev/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:2078
    #9 0x852223 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/keithb/dev/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:2114
    #10 0x84a67b in testing::Test::Run() /home/keithb/dev/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:2151
    #11 0x84a854 in testing::Test::Run() /home/keithb/dev/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:2142
    #12 0x84a854 in testing::TestInfo::Run() /home/keithb/dev/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:2326
    #13 0x84a9c4 in testing::TestInfo::Run() /home/keithb/dev/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:2301
    #14 0x84a9c4 in testing::TestCase::Run() /home/keithb/dev/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:2444
    #15 0x84ae44 in testing::TestCase::Run() /home/keithb/dev/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:4353
    #16 0x84ae44 in testing::internal::UnitTestImpl::RunAllTests() /home/keithb/dev/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:4315
    #17 0x8526d3 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/keithb/dev/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:2078
    #18 0x8526d3 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/keithb/dev/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:2114
    #19 0x84b164 in testing::UnitTest::Run() /home/keithb/dev/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:3926
    #20 0x43b830 in RUN_ALL_TESTS() /home/keithb/dev/yaml-cpp/test/gmock-1.7.0/gtest/include/gtest/gtest.h:2288
    #21 0x43b830 in main /home/keithb/dev/yaml-cpp/test/main.cpp:5
    #22 0x7f33ad22482f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #23 0x4506f8 in _start (/home/keithb/dev/yaml-cpp/build/test/run-tests+0x4506f8)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/keithb/dev/yaml-cpp/test/gmock-1.7.0/include/gmock/gmock-spec-builders.h:1373 in testing::internal::ActionResultHolder<void>::GetValueAndDelete() const
==15648==ABORTING

My OS & compiler version:

$ cat /etc/*release*
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"
NAME="Ubuntu"
VERSION="16.04.2 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.2 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
$ gcc --version
gcc (Ubuntu 6.2.0-3ubuntu11~16.04) 6.2.0 20160901
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@keith-bennett-gbg
Copy link
Author

Note that it appears that upgrading gmock to the latest Googletest appears to resolve the issue for me.

keith-bennett-gbg added a commit to keith-bennett-gbg/yaml-cpp that referenced this issue Mar 21, 2017
1. bring gmock and gtest up to date, to aa148eb2b7f70ede0eb10de34b6254826bfb34f4
@jbeder
Copy link
Owner

jbeder commented Aug 25, 2017

Fixed by #494.

@jbeder jbeder closed this as completed Aug 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants