简体   繁体   English

执行std :: deque-> front()时'deque iterator not dereferencable`

[英]'deque iterator not dereferencable` while doing std::deque->front()

following piece of code causes an assert "deque iterator not dereferencable" followed by an exception: 以下代码段导致断言“不可取消deque迭代器”和异常:

if (data[n].stateFlagQueue->empty()) cstate=0;
else
{
   cstate=data[n].stateFlagQueue->front();
   if (data[n].stateFlagQueue->size()>1) data[n].stateFlagQueue->pop();
}

The assert happens with data[n].stateFlagQueue->front() while stateflagQueue has a size of 3, so there are enough data available. 断言发生在data [n] .stateFlagQueue-> front()上,而stateflagQueue的大小为3,因此有足够的可用数据。 The whole code shown above is secured by a mutex, same is true for the code that runs in an own thread and fills stateFlagQueue with data: 上面显示的整个代码是由互斥锁保护的,对于在自己的线程中运行并用数据填充stateFlagQueue的代码也是如此:

if ((data->stateFlagQueue->empty()) || 
    (data->stateFlagQueue->back()!=data->m_response.cstate))
 data->stateFlagQueue->push(data->m_response.cstate);

So...how can it happen this exception still occurs? 那么...怎么可能发生这种异常呢?

Thanks! 谢谢!

好了,解决了,这之间发生了错误的互斥锁解锁,从而导致了此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM