Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6100223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:21:40+00:00 2026-05-23T13:21:40+00:00

When I define my test as follows it works. TEST(MyService, WhenCalled_DoesTheRightThingTM) { // Arrange

  • 0

When I define my test as follows it works.

TEST(MyService, WhenCalled_DoesTheRightThingTM) {

    // Arrange
    ThirdPartyClassFake stub;

    EXPECT_CALL(stub, GetFirstName())
        .WillRepeatedly(Return("Bob"));

    // Act
    std::string result = stub.GetFirstName();

    // Assert
    EXPECT_STREQ("Bob", result);
}

ThirdPartyClassFake is a google mock class I created.

When I add code that passes a pointer to my stub to a wrapper class I get a leaked memory error:

TEST(MyService, WhenCalled_DoesTheRightThingTM) {

    // Arrange
    ThirdPartyClassFake stub;

    EXPECT_CALL(stub, GetFirstName())
        .WillRepeatedly(Return("Bob"));

    // Act
    MyWrapperClass wrapper(&stub);
    std::string result = stub.GetFirstName();

    // Assert
    EXPECT_STREQ("Bob", result);
}

The error is:

1>  [ RUN      ] MyService.WhenCalled_DoesTheRightThingTM
1>unknown file : error : SEH exception with code 0xc0000005 thrown in the test body.
1>  [  FAILED  ] MyService.WhenCalled_DoesTheRightThingTM (1 ms)

1>c:\myfile.cpp(17): error : this mock object (used in test
MyService.WhenCalled_DoesTheRightThingTM) should be deleted but never is.
Its address is @0028E40C.
1>EXEC : error : 1 leaked mock object found at program exit.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5):
error MSB3073: The command "C:\MyProject.Tests.exe
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5):
error MSB3073: :VCEnd" exited with code 1.

Not sure if it’s relevant but I should add that ThirdPartyClassFake subclasses from a 3rd party abstract class (which I have no control over) with all virtual methods but no virtual destructor. Also it is declared with the Microsoft-specific attribute __declspec(novtable).

I thought the issue might be with the lack of a virtual destructor as described in the Google Mock FAQ. However I believe if that was the issue the first test should fail too.

How do I fix/workaround this error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:21:41+00:00Added an answer on May 23, 2026 at 1:21 pm

    0xc0000005 is Access Violation, from memory. What’s likely is that this SEH exception was thrown and the destructor wasn’t called properly if you didn’t compile the code with the right switches.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When using C preprocessor one can stringify macro argument like this: #define TO_STRING(x) a
I have a file named KernelUtil.cu as follows __device__ int add(int a, int b)
I'm getting an error here that says I haven't defined a method, but it
I have a new web app that is packaged as a WAR as part
I am having a problem returning an ArrayList from my web service (Java). I
I have put together a HTTP driven API using the WCF WebAPI that uses
I've been looking for the answer to this question but it seems quite difficult
I have a C# app that calls a C++ DLL. In C#, I have
I'm trying to use MappingJacksonJsonView with Spring 3.0, without success. I don't know what
I'm trying to work on a cross-platform project that uses boost for the file/directory

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.