小编Jah*_*bar的帖子

boost scoped_lock mutex崩溃

我在这些函数中保护了std :: queue的访问函数,push,pop,size,boost :: mutexes和boost :: mutex :: scoped_lock

它不时在一个范围内的锁中崩溃

调用堆栈是这样的:

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;
Run Code Online (Sandbox Code Playgroud)

它在此函数的最后一个粘贴行崩溃:

    inline bool interlocked_bit_test_and_set(long* x,long bit)
    {
        long const value=1<<bit;
        long old=*x;
Run Code Online (Sandbox Code Playgroud)

和x有这个值:0xababac17

谢谢您的帮助

c++ multithreading boost

6
推荐指数
1
解决办法
2677
查看次数

标签 统计

boost ×1

c++ ×1

multithreading ×1