boost scoped_lock mutex crashes

Posted by JahSumbar on Stack Overflow See other posts from Stack Overflow or by JahSumbar
Published on 2010-05-21T12:26:29Z Indexed on 2010/05/21 12:30 UTC
Read the original article Hit count: 182

Filed under:
|
|
|

hello,

I have protected a std::queue's access functions, push, pop, size, with boost::mutexes and boost::mutex::scoped_lock in these functions

from time to time it crashes in a scoped lock

the call stack is this:

0  0x0040f005  boost::detail::win32::interlocked_bit_test_and_set  include/boost/thread/win32/thread_primitives.hpp  361
1  0x0040e879  boost::detail::basic_timed_mutex::timed_lock  include/boost/thread/win32/basic_timed_mutex.hpp  68
2  0x0040e9d3  boost::detail::basic_timed_mutex::lock  include/boost/thread/win32/basic_timed_mutex.hpp  64
3  0x0040b96b  boost::unique_lock<boost::mutex>::lock  include/boost/thread/locks.hpp  349
4  0x0040b998  unique_lock  include/boost/thread/locks.hpp  227
5  0x00403837  MyClass::inboxSize - this is my inboxSize function that uses this code:

MyClass::inboxSize ()
{
 boost::mutex::scoped_lock scoped_lock(m_inboxMutex);
 return m_inbox.size();
}

and the mutex is declared like this:
boost::mutex    m_inboxMutex;

it crashes at the last pasted line in this function:

    inline bool interlocked_bit_test_and_set(long* x,long bit)
    {
        long const value=1<<bit;
        long old=*x;

and x has this value: 0xababac17

Thanks for the help

© Stack Overflow or respective owner

Related posts about c++

Related posts about boost