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

Pthread_mutex_lock &mutex Failed With Error 22

from GoogleSign inHidden fieldsSearch for groups or messages

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 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up pthread-related errors when upgrading test from GoogleTest to https://groups.google.com/d/topic/googlemock/o0spo6ZR08A 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 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 http://stackoverflow.com/questions/30865653/pthread-related-errors-when-upgrading-test-from-googletest-to-googlemock-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 features yielded similar errors. Build info: Ubuntu 14.04 gcc 4.8.2 gmock 1.7.0 is downloaded and built with CMAKE: wget https://googlemock.googlecode.com/files/gmock-1.7.0.zip unzip gmock-1.7.0.zip GMOCK_PATH=$PWD/gmock-1.7.0 GTEST_PATH=$GMOCK_PATH/gtest mkdir $GMOCK_PATH/lib $GTEST_PATH/lib pushd $GMOCK_PATH/lib cmake -DBUILD_SHARED_LIBS=ON .. make cd $GTEST_PATH/lib cmake -DBUILD_SHARED_LIBS=ON .. make popd Finally, the whole project is built using Qt's qmake: INCLUDEPATH += $${GMOCK_PATH}/incl

Forum Visual C++ & C++ Programming C++ (Non Visual C++ Issues) pthread_mutex_lock fails If this is your first visit, be sure to check out http://forums.codeguru.com/showthread.php?508898-pthread_mutex_lock-fails the FAQ by clicking the link above. You may have to register or Login before you can post: click the register link above to proceed. To start viewing messages, select the forum https://sourceware.org/ml/libc-help/2008-05/msg00071.html that you want to visit from the selection below. Results 1 to 6 of 6 Thread: pthread_mutex_lock fails Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display pthread_mutex_lock &mutex Linear Mode Switch to Hybrid Mode Switch to Threaded Mode February 18th, 2011,12:40 AM #1 srinivasant View Profile View Forum Posts Junior Member Join Date Jul 2007 Posts 15 pthread_mutex_lock fails Hi, I have linked statically libodbc++ (libodbc++-mt.a) with my CPP application and connect to MySQL from various threads simultaneously from my application. At some point my application crashes with the following error, terminate called pthread_mutex_lock &mutex failed after throwing an instance of 'odbc::SQLException' what(): [libodbc++]: OS error, mutex lock failed HY000 : [libodbc++]: OS error, mutex lock failed :: [Open DB] : IN DB /home/test/Users/Srini/xxxxxxx/dbnamexxx terminate called recursively HY000 : [libodbc++]: OS error, mutex lock failed :: [Open DB] : IN DB /home/test/Users/Srini/xxxxxxx/dbnamexxx terminate called recursively HY000 : [libodbc++]: OS error, mutex lock failed :: [Open DB] : IN DB /home/test/Users/Srini/xxxxxxx/dbnamexxx Aborted Seems the pthread_mutex_lock() in src/threads.cpp fails with error and libodbc throws exception and hence application crashes (running in my application in debug mode). I have checked the return value of pthread_mutex_lock() and it is EINVAL (22) which means Invalid Argument. The details of my setup is as follows, OS : Cent OS 5.3 libodbc++ : v0.2.3 unixODBC : v2.2.15pre MySQL Driver : v3.51.27 MySQL Server : v5.1.39 My odbcinst.ini file is as follows, -------------------8<---------------------- [ODBC] Trace = No Trace File = /tmp/sql.log Pooling = Yes [MySQL] Description = Driver = /usr/local/lib/libmyodbc3-3.51.27.so Driver64 = Setup = /usr/local/lib/libmyodbc3S-3.51.27.so Setup64 = UsageCount =1 CPTimeout =300 CPReuse =1 Threading =0 ------------------->8---------------------- My configure option for libodbc++ is as follows, ./configure --enable-static=yes --with-odbc=/home/path/to/unixodbc/unixODBC-2.2.15pre/DriverManager/.libs/ --enable-threads=yes I have also tested with libodbc++ v0.

text] Strange error locking a pthread mutex... From: "Kris van Rens" To: libc-help at sourceware dot org Date: Thu, 22 May 2008 18:20:01 +0200 Subject: Strange error locking a pthread mutex... Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=/FKsPK1XG/7OdxBaUdS0eVplxKUBjJ9f9ApzGAKRK0A=; b=vtRenChjk5ip/mNvdM3+YwQhp22FnMAkJgR/lUGiiR3hticldJRMk9bGGORF8/iwIVmT4LFQO4jhQSlbIiftdO0hxhi4FteEW1JIKDNhiBJZT4uHkQ16Lc7Kc0heSSG0nHqMsbGy/zxRExBsppMcSZfG5so4eBFFByDX4Jy5Zrw= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=AeVa5qbgmSYFKGWRdyuXu5uNUcQUVgyoBloNePC9mAxsP/nrt4j6LLpKGLsbCwgZNhFT4jKW9eRzeovHxCFLH/ghK/KX0bNNlRQrxCUNmXrOlUKi1lKHgOqhORpYP6ESojWhavXIbS5uGbzq+9syLN7BXgJmzfpUm1Uza7Bwnjw= Hi there, I'm experiencing peculiar problems using a pthread mutex in my program. Let me try to explain the setup of the program: There is a main thread which initializes a recursive mutex for use within (multiple) event threads running along the main thread, the mutex is used for (what a surprise) outlining a critical section. Here is a diagram (plaintext, ASCII-art): +------------------+ | main() thread | +------------------+ | ... | | initialize mutex | | ... | | spawn threads ---+-------------+------------------------+-------------// | ... | | | = = +------------------+ +------------------+ +------------------+ | event thread1 | | event thread2 | +------------------+ +------------------+ | ... | | ... | | lock mutex | | lock mutex | | | | | | unlock mutex | | unlock mutex | | ... | | ... | +------------------+ +------------------+ The mutex variable is declared globally and initialised in the main thread. ---(globally) pthread_mutex_t CritSec; --- The initialisation of the mutex is being done as follo

 

Related content

pthread_mutex_lock &mutex failed with error

Pthread mutex lock mutex Failed With Error p from GoogleSign inHidden fieldsSearch for groups or messages p p with error 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 pthread mutex lock mutex failed with error 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