I am getting an assertion in boost::mutex while using static mutex variables. Below is the stack trace for that. void boost::mutex::lock(): Assertion `!pthread_mutex_lock(&m)' failed. #0 0xb7f9f410 in __kernel_vsyscall () #1 0xb75f1085 in raise () from /lib/tls/i686/cmov/libc.so.6 #2 0xb75f2a01 in abort () from /lib/tls/i686/cmov/libc.so.6 #3 0xb75ea10e in __assert_fail () from /lib/tls/i686/cmov/libc.so.6 #4 0x080581eb in ~mutex (this=0x80f3ab8) at boost/thread/pthread/mutex.hpp:45 #5 0x0805f202 in __tcf_7 () at TimerQueue.cpp:22 #6 0xb75f4084 in exit () from /lib/tls/i686/cmov/libc.so.6 #7 0xb75dc458 in __libc_start_main () from /lib/tls/i686/cmov/libc.so.6 #8 0x080546c1 in _start () Any pointers/suggestions? -- ------------------------------------------------------------------- Ph : (732) 647 5679 Email: khandelwal.amit@gmail.com Web: http://khandelwal.amit.googlepages.com/home -------------------------------------------------------------------
On Fri, Oct 3, 2008 at 3:50 PM, amit khandelwal
I am getting an assertion in boost::mutex while using static mutex variables. Below is the stack trace for that.
void boost::mutex::lock(): Assertion `!pthread_mutex_lock(&m)' failed.
Was the assertion failure for pthread_mutex_lock(), or pthread_mutex_destroy()? Your assertion message has the former, but the back-trace indicates the latter. Either way, the cause might be static initialization order. Do you have a global object whose destructor makes use (directly, or indirectly through any contained classes' destructors) of a mutex which is also part of some global object? -- Matthew L. Creech
I created a sample test harness to use the code that was causing this. It
happens when the program is about to shutdown (at the destruction time).
This text was printed by boost "void boost::mutex::lock(): Assertion
`!pthread_mutex_lock(&m)' failed."
The mutex is not used in the destructor. Below are the details of the exact
frame.
(gdb) fr 4
#4 0x08053631 in ~mutex (this=0x80e5998) at
/inc/boost/thread/pthread/mutex.hpp:45
45 BOOST_VERIFY(!pthread_mutex_destroy(&m));
(gdb) p m
$1 = {__data = {__lock = 1, __count = 0, __owner = 3470, __kind = 0,
__nusers = 1, {__spins = 0, __list = {__next = 0x0}}},
__size =
"\001\000\000\000\000\000\000\000\216\r\000\000\000\000\000\000\001\000\000\000\000\000\000",
__align = 1}
Why should it crash the system?
On Fri, Oct 3, 2008 at 4:37 PM, Matthew L. Creech
On Fri, Oct 3, 2008 at 3:50 PM, amit khandelwal
wrote: I am getting an assertion in boost::mutex while using static mutex variables. Below is the stack trace for that.
void boost::mutex::lock(): Assertion `!pthread_mutex_lock(&m)' failed.
Was the assertion failure for pthread_mutex_lock(), or pthread_mutex_destroy()? Your assertion message has the former, but the back-trace indicates the latter.
Either way, the cause might be static initialization order. Do you have a global object whose destructor makes use (directly, or indirectly through any contained classes' destructors) of a mutex which is also part of some global object?
-- Matthew L. Creech _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- ------------------------------------------------------------------- Ph : (732) 647 5679 Email: khandelwal.amit@gmail.com Web: http://khandelwal.amit.googlepages.com/home -------------------------------------------------------------------
participants (2)
-
amit khandelwal
-
Matthew L. Creech