{"action":"created","issue":{"url":"https://api.github.com/repos/google/googletest/issues/705","repository_url":"https://api.github.com/repos/google/googletest","labels_url":"https://api.github.com/repos/google/googletest/issues/705/labels{/name}","comments_url":"https://api.github.com/repos/google/googletest/issues/705/comments","events_url":"https://api.github.com/repos/google/googletest/issues/705/events","html_url":"https://github.com/google/googletest/issues/705","id":130934790,"number":705,"title":"Undefined behavior \"member call on null pointer of type 'const struct ResultHolder'\"","user":{"login":"octoploid","id":327746,"avatar_url":"https://avatars.githubusercontent.com/u/327746?v=3","gravatar_id":"","url":"https://api.github.com/users/octoploid","html_url":"https://github.com/octoploid","followers_url":"https://api.github.com/users/octoploid/followers","following_url":"https://api.github.com/users/octoploid/following{/other_user}","gists_url":"https://api.github.com/users/octoploid/gists{/gist_id}","starred_url":"https://api.github.com/users/octoploid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/octoploid/subscriptions","organizations_url":"https://api.github.com/users/octoploid/orgs","repos_url":"https://api.github.com/users/octoploid/repos","events_url":"https://api.github.com/users/octoploid/events{/privacy}","received_events_url":"https://api.github.com/users/octoploid/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-03T07:08:05Z","updated_at":"2016-02-03T15:49:27Z","closed_at":null,"body":"Compiling with gcc-6 leads to segfaults in projects that use googletest, \r\nbecause it invokes undefined behavior.\r\n\r\nFor example the yaml-cpp testsuite segfaults: \r\n`\r\n/var/tmp/yaml-cpp/test/gmock-1.7.0/include/gmock/gmock-spec-builders.h:1530:60: runtime error: member call on null pointer of type 'const struct ResultHolder'`\r\n`[1]    20019 segmentation fault  ./run-tests`\r\n\r\n\"this\" must never be NULL in C++.\r\nUsing \"-fno-delete-null-pointer-checks\" is a workaround. \r\n\r\n```\r\n1579   // Returns the result of invoking this mock function with the given                                                                                                    \r\n1580   // arguments.  This function can be safely called from multiple                                                                                                        \r\n1581   // threads concurrently.                                                                                                                                               \r\n1582   Result InvokeWith(const ArgumentTuple& args)                                                                                                                           \r\n1583         GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {                                                                                                                            \r\n1584     scoped_ptr<ResultHolder> holder(                                                                                                                                     \r\n1585         DownCast_<ResultHolder*>(this->UntypedInvokeWith(&args)));                                                                                                       \r\n1586     return holder->Unwrap();                                                                                                                                             \r\n1587   }  \r\n```"},"comment":{"url":"https://api.github.com/repos/google/googletest/issues/comments/179302822","html_url":"https://github.com/google/googletest/issues/705#issuecomment-179302822","issue_url":"https://api.github.com/repos/google/googletest/issues/705","id":179302822,"user":{"login":"octoploid","id":327746,"avatar_url":"https://avatars.githubusercontent.com/u/327746?v=3","gravatar_id":"","url":"https://api.github.com/users/octoploid","html_url":"https://github.com/octoploid","followers_url":"https://api.github.com/users/octoploid/followers","following_url":"https://api.github.com/users/octoploid/following{/other_user}","gists_url":"https://api.github.com/users/octoploid/gists{/gist_id}","starred_url":"https://api.github.com/users/octoploid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/octoploid/subscriptions","organizations_url":"https://api.github.com/users/octoploid/orgs","repos_url":"https://api.github.com/users/octoploid/repos","events_url":"https://api.github.com/users/octoploid/events{/privacy}","received_events_url":"https://api.github.com/users/octoploid/received_events","type":"User","site_admin":false},"created_at":"2016-02-03T15:49:27Z","updated_at":"2016-02-03T15:49:27Z","body":"```\r\nmarkus@x4 test % gdb ./run-tests\r\nReading symbols from ./run-tests...done.\r\n(gdb) b __ubsan::Diag::~Diag\r\n(gdb) run\r\n...\r\nBreakpoint 1, 0x00007ffff6dfec40 in __ubsan::Diag::~Diag() () from /usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0/libubsan.so.0\r\n(gdb) bt\r\n#0  0x00007ffff6dfec40 in __ubsan::Diag::~Diag() () from /usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0/libubsan.so.0\r\n#1  0x00007ffff6e02241 in handleTypeMismatchImpl(__ubsan::TypeMismatchData*, unsigned long, __ubsan::ReportOptions) ()\r\n   from /usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0/libubsan.so.0\r\n#2  0x00007ffff6e026d3 in __ubsan_handle_type_mismatch () from /usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0/libubsan.so.0\r\n#3  0x00000000005003dc in testing::internal::FunctionMockerBase<void (YAML::Mark const&)>::InvokeWith(std::tuple<YAML::Mark const&> const&) (\r\n    args=std::tuple containing = {...}, this=0x2842350) at /var/tmp/yaml-cpp/test/gmock-1.7.0/include/gmock/gmock-spec-builders.h:1530\r\n#4  testing::internal::FunctionMocker<void (YAML::Mark const&)>::Invoke(YAML::Mark const&) (a1=..., this=0x2842350)\r\n    at /var/tmp/yaml-cpp/test/gmock-1.7.0/include/gmock/gmock-generated-function-mockers.h:97\r\n#5  YAML::MockEventHandler::OnDocumentStart (this=<optimized out>, gmock_a1=...) at /var/tmp/yaml-cpp/test/mock_event_handler.h:10\r\n#6  0x0000000001320f0f in YAML::SingleDocParser::HandleDocument (this=0x7fffffffda10, eventHandler=...) at /var/tmp/yaml-cpp/src/singledocparser.cpp:31\r\n#7  0x00000000012686f5 in YAML::Parser::HandleNextDocument (this=this@entry=0x7fffffffdc50, eventHandler=...) at /var/tmp/yaml-cpp/src/parser.cpp:42\r\n#8  0x00000000004f9717 in YAML::HandlerTest::Parse (\r\n    example=\"- |\\n  !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\n- |\\n  ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍ\", <\r\nincomplete sequence \\303>..., this=0x2842330) at /var/tmp/yaml-cpp/test/handler_test.h:17\r\n#9  YAML::(anonymous namespace)::EncodingTest::Run (this=0x2842330) at /var/tmp/yaml-cpp/test/integration/encoding_test.cpp:105\r\n#10 0x000000000145896b in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void> (location=0x14b5616 \"the test body\", method=<optimized out>, \r\n    object=0x2842330) at /var/tmp/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:2078\r\n#11 testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void> (object=object@entry=0x2842330, method=<optimized out>, \r\n    location=location@entry=0x14b5616 \"the test body\") at /var/tmp/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:2114\r\n#12 0x00000000014226da in testing::Test::Run (this=this@entry=0x2842330) at /var/tmp/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:2151\r\n#13 0x00000000014231a3 in testing::Test::Run (this=0x2842330) at /var/tmp/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:2142\r\n#14 testing::TestInfo::Run (this=0x27fc3d0) at /var/tmp/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:2326\r\n#15 0x0000000001423de8 in testing::TestCase::Run (this=0x27fc4c0) at /var/tmp/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:2444\r\n#16 0x00000000014256ca in testing::internal::UnitTestImpl::RunAllTests (this=0x27f4d70) at /var/tmp/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:4315\r\n#17 0x0000000001459bcb in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (\r\n    location=0x14ab870 \"auxiliary test code (environments or event listeners)\", method=<optimized out>, object=0x1424960 <testing::internal::UnitTestImpl::RunAllTests()>)\r\n    at /var/tmp/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:2078\r\n#18 testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=object@entry=0x27f4d70, method=<optimized out>, \r\n    location=location@entry=0x14ab870 \"auxiliary test code (environments or event listeners)\") at /var/tmp/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:2114\r\n#19 0x0000000001427519 in testing::UnitTest::Run (this=0x27e1a00 <testing::UnitTest::GetInstance()::instance>) at /var/tmp/yaml-cpp/test/gmock-1.7.0/gtest/src/gtest.cc:3926\r\n#20 0x0000000000455f08 in RUN_ALL_TESTS () at /var/tmp/yaml-cpp/test/gmock-1.7.0/gtest/include/gtest/gtest.h:2288\r\n#21 main (argc=<optimized out>, argv=<optimized out>) at /var/tmp/yaml-cpp/test/main.cpp:5\r\n(gdb) up\r\n#1  0x00007ffff6e02241 in handleTypeMismatchImpl(__ubsan::TypeMismatchData*, unsigned long, __ubsan::ReportOptions) ()\r\n   from /usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0/libubsan.so.0\r\n(gdb) up\r\n#2  0x00007ffff6e026d3 in __ubsan_handle_type_mismatch () from /usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0/libubsan.so.0\r\n(gdb) up\r\n#3  0x00000000005003dc in testing::internal::FunctionMockerBase<void (YAML::Mark const&)>::InvokeWith(std::tuple<YAML::Mark const&> const&) (\r\n    args=std::tuple containing = {...}, this=0x2842350) at /var/tmp/yaml-cpp/test/gmock-1.7.0/include/gmock/gmock-spec-builders.h:1530\r\n1530            this->UntypedInvokeWith(&args))->GetValueAndDelete();\r\n(gdb) l\r\n1525      // arguments.  This function can be safely called from multiple\r\n1526      // threads concurrently.\r\n1527      Result InvokeWith(const ArgumentTuple& args)\r\n1528            GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\r\n1529        return static_cast<const ResultHolder*>(\r\n1530            this->UntypedInvokeWith(&args))->GetValueAndDelete();\r\n1531      }\r\n1532\r\n1533      // Adds and returns a default action spec for this mock function.\r\n1534      OnCallSpec<F>& AddNewOnCallSpec(\r\n(gdb) p this\r\ntesting::internal::FunctionMockerBase<void(const YAML::Mark&)> * const) 0x2842350\r\n(gdb) p *this\r\n{\r\n  <testing::internal::UntypedFunctionMockerBase> = {\r\n    _vptr.UntypedFunctionMockerBase = 0x14c05a8 <vtable for testing::internal::FunctionMocker<void (YAML::Mark const&)>+16>, \r\n    mock_obj_ = 0x2842348, \r\n    name_ = 0x14ad1c7 \"OnDocumentStart\", \r\n    untyped_on_call_specs_ = std::vector of length 0, capacity 0, \r\n    untyped_expectations_ = std::vector of length 1, capacity 1 = {{\r\n        value_ = 0x283e390, \r\n        link_ = {\r\n          next_ = 0x283f588\r\n        }\r\n      }}\r\n  }, \r\n  members of testing::internal::FunctionMockerBase<void(const YAML::Mark&)>: \r\n  current_spec_ = {\r\n    function_mocker_ = 0x2842350, \r\n    matchers_ = std::tuple containing = {\r\n      [1] = {\r\n        <testing::internal::MatcherBase<YAML::Mark const&>> = {\r\n          _vptr.MatcherBase = 0x14c0538 <vtable for testing::Matcher<YAML::Mark const&>+16>, \r\n          impl_ = {\r\n            value_ = 0x283d040, \r\n            link_ = {\r\n              next_ = 0x283e490\r\n            }\r\n          }\r\n        }, <No data fields>}\r\n    }\r\n  }\r\n}\r\n(gdb) p this->UntypedInvokeWith(&args)\r\n$5 = (const testing::internal::UntypedActionResultHolderBase *) 0x0\r\n"}}