I have following code somewhere in my application:
struct StreamFrame
{
cv::Mat imageDataRGB;
cv::Mat imageDataBGR;
FILETIME currentTime;
std::vector<int8_t> metaData;
int32_t dataLength;
};
StreamData::StreamFrame StreamData::GetMetaData()
{
mtx.lock();
if (!sfQueue.empty())
{
single = sfQueue.front(); // the line causing the error
sfQueue.pop();
}
mtx.unlock();
return single;
}
For some reason I keep getting a deque iterator not dereferencable
error, but my queue is a) not empty (18 elements in it when the error occurs), and b) threading should not be an issue since everything is locked via mutex.
What can I do to debug this? Note, this code has passed a million times already, and suddently it fails, and I have absolutely zip idea why this might happen.
Edit:
Definition of streamframe:
std::queue<StreamFrame> sfQueue;
Receiving a streamframe:
void StreamData::ReceiveFrame(StreamFrame* input, bool init)
{
StreamFrame oneSF;
oneSF.imageDataRGB = input->imageDataRGB.clone();
oneSF.imageDataBGR = input->imageDataBGR.clone();
oneSF.currentFrameTime = input->currentFrameTime;
oneSF.metaData = input->metaData;
oneSF.metaDataLength = input->metaDataLength;
mtx.lock();
sfQueue.push(oneSF);
mtx.unlock();
}