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

leaked mock objects aren't detected by leak checkers #24

Closed
GoogleCodeExporter opened this issue Jun 25, 2015 · 5 comments
Closed

leaked mock objects aren't detected by leak checkers #24

GoogleCodeExporter opened this issue Jun 25, 2015 · 5 comments

Comments

@GoogleCodeExporter
Copy link

ON_CALL and EXPECT_CALL cause a mock object to be referenced in a global
table Google Mock keeps.  Therefore if the user code forgets to delete a
mock object, a leak checker won't be able to detect it since the object is
still reachable from the global table.  This is bad as the verification of
expectations is done in the mock object's destructor.

We should use some kind of weak pointer instead of void* to reference the
mock objects in the global table.

Original issue reported on code.google.com by zhanyong...@gmail.com on 6 Feb 2009 at 7:48

@GoogleCodeExporter
Copy link
Author

Vlad suggested:

> Why can't googlemock release all the pointers before exiting RUN_ALL_TESTS 
when
> run under gtest?

Good point.  Better yet, googlemock could report them as errors.  This is
especially useful where a heap checker cannot be used.

> This can be done once gtest's test listener interface is
> published.

Yes.  Or we can use a global test environment, which is already
supported.  We just need to make sure that googlemock's environment is torn
down after all other test environments.


Original comment by zhanyong...@gmail.com on 26 Feb 2009 at 7:11

@GoogleCodeExporter
Copy link
Author

Original comment by zhanyong...@gmail.com on 26 Feb 2009 at 7:11

  • Added labels: Priority-High
  • Removed labels: Priority-Medium

@GoogleCodeExporter
Copy link
Author

Original comment by zhanyong...@gmail.com on 4 Mar 2009 at 7:15

  • Added labels: Usability

@GoogleCodeExporter
Copy link
Author

A simple solution is to add a destructor to the global table which will 
complain if
the table is not empty.

Original comment by zhanyong...@gmail.com on 15 Apr 2009 at 11:31

@GoogleCodeExporter
Copy link
Author

Original comment by zhanyong...@gmail.com on 1 May 2009 at 7:47

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant