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

Crash caused by missing lock #165

Open
GoogleCodeExporter opened this issue Apr 2, 2015 · 4 comments
Open

Crash caused by missing lock #165

GoogleCodeExporter opened this issue Apr 2, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

FunctionMockerBase<F>::AddNewExpectation() modifies untyped_expectations_ 
without locking g_gmock_mutex.
It can cause a crash if another thread calls the same function or 
FindMatchingExpectationLocked().

Google Mock version: 1.7.0

Original issue reported on code.google.com by n...@tresorit.com on 11 Nov 2013 at 6:49

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

It's pretty important, googlemock always crashes when used from multiple 
threads...

Original comment by n...@tresorit.com on 22 Oct 2014 at 11:09

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Expectations must be set when setting up the mock, before calling the mock 
methods.

From the document at https://code.google.com/p/googlemock/wiki/V1_7_ForDummies:

"Important note: Google Mock requires expectations to be set before the mock 
functions are called, otherwise the behavior is undefined. In particular, you 
mustn't interleave EXPECT_CALL()s and calls to the mock functions."

Original comment by sbe...@google.com on 22 Oct 2014 at 4:25

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

The crash also happens if multiple threads call EXPECT_CALL at the same time, I 
think that should work.

Original comment by n...@tresorit.com on 27 Oct 2014 at 4:12

  • Added labels: ****
  • Removed labels: ****

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