Package: google-mocks
Version: 1.7.0-18092013-2
User: [email protected]
Usertags: origin-ubuntu yakkey


The fix provided for bug #812289 doesn't fix all the cases.

In Ubunutu we use google-mocks in unity and when using gcc-6, things
doesn't work well when mocking some function.

Starting program:
/tmp/unity-7.5.0+16.10.20160804/obj-x86_64-linux-gnu/tests/test-gtest
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffe0f1d700 (LWP 22778)]
[New Thread 0x7fffdbfff700 (LWP 22779)]
[New Thread 0x7fffdb7fe700 (LWP 22780)]
[==========] Running 1637 tests from 105 test cases.
[----------] Global test environment set-up.
[----------] 14 tests from TestActionLink
[ RUN ] TestActionLink.AligmentCorrectlySetDifferent

Thread 1 "test-gtest" received signal SIGSEGV, Segmentation fault.
testing::internal::FunctionMockerBase<void ()>::InvokeWith(std::tuple<>
const&) (args=empty std::tuple, this=0x7fffffffdb08)
    at /usr/include/gmock/gmock-spec-builders.h:1530
1530 this->UntypedInvokeWith(&args))->GetValueAndDelete();

#0 testing::internal::FunctionMockerBase<void
()>::InvokeWith(std::tuple<> const&) (args=empty std::tuple,
this=0x7fffffffdb08)
    at /usr/include/gmock/gmock-spec-builders.h:1530
No locals.
#1 testing::internal::FunctionMocker<void ()>::Invoke()
(this=0x7fffffffdb08) at
/usr/include/gmock/gmock-generated-function-mockers.h:76
No locals.
#2 unity::dash::ActionLinkMock::QueueDraw (this=0x7fffffffd3c0) at
/tmp/unity-7.5.0+16.10.20160804/tests/test_action_link.cpp:43
No locals.
#3 0x00005555559ce574 in unity::dash::ActionLink::set_underline
(this=0x7fffffffd3c0, underline=unity::StaticCairoText::NUX_UNDERLINE_NONE)
    at
/tmp/unity-7.5.0+16.10.20160804/tests/../dash/previews/ActionLink.cpp:218
No locals.
#4 0x00005555559d53bf in std::function<bool
(unity::StaticCairoText::UnderlineState
const&)>::operator()(unity::StaticCairoText::UnderlineState const&)
const (__args#0=<optimized out>, this=0x7fffffffda00) at
/usr/include/c++/6/functional:2136
No locals.
#5 nux::RWProperty<unity::StaticCairoText::UnderlineState>::Set
(this=0x7fffffffd9c8, value=<optimized out>)
    at /usr/include/Nux-4.0/NuxCore/Property-inl.h:218
No locals.
#6 0x00005555559d0c31 in
unity::dash::TestActionLink_UnderlineCorrectlySetDifferent_Test::TestBody
(this=<optimized out>)
    at /tmp/unity-7.5.0+16.10.20160804/tests/test_action_link.cpp:116


The change provided at
https://github.com/google/googletest/issues/705#issuecomment-235067917
and attached here is enough to entirely fix this issue.


Fix for ubuntu, with provided debdiff is http://pad.lv/1609793
Author: Romain Geissler
Origin: https://github.com/google/googletest/issues/705#issuecomment-235067917
Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=812289
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/google-mock/+bug/1609793
Forwarded: not-needed

--- a/include/gmock/gmock-spec-builders.h
+++ b/include/gmock/gmock-spec-builders.h
@@ -1370,6 +1370,8 @@
 template <>
 class ActionResultHolder<void> : public UntypedActionResultHolderBase {
  public:
+  explicit ActionResultHolder() {}
+
   void GetValueAndDelete() const { delete this; }

   virtual void PrintAsActionResult(::std::ostream* /* os */) const {}
@@ -1381,7 +1383,7 @@
       const typename Function<F>::ArgumentTuple& args,
       const string& call_description) {
     func_mocker->PerformDefaultAction(args, call_description);
-    return NULL;
+    return new ActionResultHolder();
   }

   // Performs the given action and returns NULL.
@@ -1390,7 +1392,7 @@
       const Action<F>& action,
       const typename Function<F>::ArgumentTuple& args) {
     action.Perform(args);
-    return NULL;
+    return new ActionResultHolder();
   }
 };

Reply via email to