title: Segmentation fault while running Google test
body: <p>I am getting a segmentation fault when I try running gtest by mocking a method that accepts pointer to a object as the argument. I identified the mock method that is creating the trouble.</p>
  
  <pre><code>class NvmControllerMockApp : NvmController_API
  { 
  
   public:
  
     MOCK_METHOD1(registerAccessor, bool(NVM_Accessor *accessor));
     MOCK_METHOD0(update, void());
  
  }
  </code></pre>
  
  <p>This is the o/p produced by gtest:</p>
  
  <pre><code>Running main() from gmock_main.cc
  [==========] Running 1 test from 1 test case.
  [----------] Global test environment set-up.
  [----------] 1 test from MeterTamperAppTest
  [ RUN      ] MeterTamperAppTest.NeutralDisturbanceCheck
  Segmentation fault (core dumped)
  </code></pre>
  
  <p>The MOCK_METHOD1 is what is creating the segmentation fault. If that method is excluded from the file that is to be tested then things seem to work fine. As a word of caution the NVM_Accessor class deals with some pointers. I have tried debugging the error using GDB and the following is the backtrace message at the point of segmentation fault : </p>
  
  <pre><code>Program received signal SIGSEGV, Segmentation fault.
  0x00000000004168d3 in testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith (this=0x67f188, untyped_args=0x7fffffffdca0)
      at ../src/gmock-spec-builders.cc:363
  363     this-&gt;UntypedDescribeUninterestingCall(untyped_args, &amp;ss);
  (gdb) backtrace
  #0  0x00000000004168d3 in testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith (this=0x67f188, untyped_args=0x7fffffffdca0)
      at ../src/gmock-spec-builders.cc:363
  #1  0x0000000000410fc9 in testing::internal::FunctionMockerBase&lt;bool (NVM_Accessor*)&gt;::InvokeWith(std::tr1::tuple&lt;NVM_Accessor*&gt; const&amp;) (
      this=0x67f188, args=...) at /home/sudeep/GramPower/gmock-1.7.0/include/gmock/gmock-spec-builders.h:1530
  #2  0x0000000000410c56 in testing::internal::FunctionMocker&lt;bool (NVM_Accessor*)&gt;::Invoke(NVM_Accessor*) (this=0x67f188, a1=0x67f148)
      at /home/sudeep/GramPower/gmock-1.7.0/include/gmock/gmock-generated-function-mockers.h:97
  #3  0x000000000041076f in NvmControllerMockApp::registerAccessor (this=0x67f180, gmock_a1=0x67f148)
      at /home/sudeep/GramPower/gpos_fw/gpos/apps/nvm_controller/mocks/nvm_controller_mock_app.h:26
  #4  0x0000000000413470 in MeterTamperApp::MeterTamperApp (this=0x67f128, env_=0x67ee90) at apps/meter_tamper/meter_tamper_app.cpp:31
  #5  0x0000000000410989 in MeterTamperAppMockEnvironment::MeterTamperAppMockEnvironment (this=0x67ee90)
      at apps/meter_tamper/tests/../mocks/meter_tamper_app_mock_environment.h:23
  #6  0x0000000000410a3e in MeterTamperAppTest::MeterTamperAppTest (this=0x67ee80) at apps/meter_tamper/tests/meter_tamper_app_dtest.cpp:30
  #7  0x0000000000410b10 in MeterTamperAppTest_NeutralDisturbanceCheck_Test::MeterTamperAppTest_NeutralDisturbanceCheck_Test (this=0x67ee80)
      at apps/meter_tamper/tests/meter_tamper_app_dtest.cpp:36
  </code></pre>