jagtesh / googlemock

Automatically exported from code.google.com/p/googlemock
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Crash caused by missing lock #165

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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