Home > pthread mutex lock mutex > pthread_mutex_lock &mutex failed with error

Pthread_mutex_lock &mutex Failed With Error

from GoogleSign inHidden fieldsSearch for groups or messages

with error 22!! Recently I came across below problem while I was writing the gmock test for our source code. gmock is a unit test framework for C++.gmock is short form of Google Mocking. gtest/internal/gtest-port.h:1151:: pthread_mutex_lock(&mutex_)failed with error 22 Abort I gotthe above error twotimes while I waswriting UT test cases.See the two scenarios below. ExtraEXPECT_CALL :This could be one of the reasons for theabove problem. In my test case I have lot ofEXPECT_CALL's, becauseour function is calling https://groups.google.com/d/topic/googlemock/o0spo6ZR08A lot ofother functions, so I need to mock all the functions,in theprocess of mocking these functions, by mistake Imockedone function which is not been called by this function.That meansI added one extra EXPECT_CALL. By taking stacktraceusing GDB I found the function and commented that expect call. And it was workingfine. Used Once instead of Repeatedly: This may also causes http://www.chanduthedev.com/2012/08/pthreadmutexlock-with-error-22.html for the above error message. With the experience of extra expect_call case, I have taken the stack trace or back trace using GDB, and I found that for one expect call I used WillOnce. So changed to WillRepeatedly. It got solved. After my analysis and contacting with our UT team, I came to know that the possible reason for this problem is that calling extra EXPECT_CALL for the unused functions. Labels: GMock 2 comments: Henry said... thank you! helped me solve my issue November 14, 2013 at 1:11 AM chanduthedev p said... Hi Henry,Thanks for your comments.CHandUtheDev November 14, 2013 at 7:24 PM Post a Comment Newer Post Older Post Home Subscribe to: Post Comments (Atom) Popular Posts delete node from binary search tree!! One of the complex operation on binary search tree is deleting a node. Insertion is easy by calling recursive insertion. But deletion wont... AVL Tree C program!!! Below is C program for AVL Tree implementation. #include #include typedef struct bst { int info; int hei... How to convert UUID to Strin

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss http://stackoverflow.com/questions/30865653/pthread-related-errors-when-upgrading-test-from-googletest-to-googlemock-ubuntu the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. pthread_mutex_lock &mutex Join them; it only takes a minute: Sign up pthread-related errors when upgrading test from GoogleTest to GoogleMock (Ubuntu 14) up vote 1 down vote favorite While trying to add gmock to an existing project that already was using gtest, I have found a series of low-level errors related to pthread. My guess is this is related to pthread_mutex_lock &mutex failed how GoogleMock & GoogleTest are built (see details below), but unfortunately there is not much information about the best way of using these libraries in Ubuntu 14. After reducing the code to a minimal representative example, what happens is: I replaced the GoogleTest headers with the GoogleMock ones, as well as the "main" function: // Declarations at foo.h class Foo { public: int sum(int a, int b); // it returns a+b (defined in foo.cpp) }; // Test code at foo.test.cpp #include // replaced #include "foo.h" TEST(Foo,ReturnsSumOfTwoNumbers){ Foo foo; ASSERT_EQ( foo.sum(2,8), 10 ); } TEST(Foo,ReturnsSumOfTwoIntegerNumbers){ Foo foo; ASSERT_EQ( 6,foo.sum(-2,8) ); } // main.cpp #include // replaced int main(int argc, char **argv) { ::testing::InitGoogleMock(&argc, argv); // replaced InitGoogleTest return RUN_ALL_TESTS(); } This works FINE. When I try to use a GoogleMock feature (e.g a matcher): // foo.test.cpp using ::testing::Eq; //... TEST(Foo,ReturnsSumOfTwoNumbers){ Foo foo; // replaced ASSERT_EQ ASSERT_THAT( foo.sum(2,8), Eq(10) ); } .. It crashes with the following error: [ FATAL ] /path/to/gmock-1.7.0/gtest/include/gtest/internal/gtest-port.h:1340:: pthread_mutex_lock(&mutex_)failed with error 22 Aborted (core dumped) Using other gmock

 

Related content

pthread_mutex_lock &mutex failed with error 22

Pthread mutex lock mutex Failed With Error p from GoogleSign inHidden fieldsSearch for groups or messages p p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of million programmers just like you helping each other Join them it only