Vector: deque iterator not dereferencable

Hi, i've got a problem with a stl vector, and i cant find any information about this error. the error is:

deque iterator not dereferencable

while(!Servers->empty()){
if (RequestServerInfo(&Servers->front())!=0){
MisScanned++;
}

else{
if (DealWithServerInfo(&Servers->front())!=0){ //ERROR LOCATION
MisScanned++;
}

after some debugging, i found that the error was at the DealWithServerInfo function call. however, i dont see why..

can anyone help. oh yeh, the time before this error occurs is different every time, somethimes its there in 2 secs, and the next time its there in 2 mins.



Answer this question

Vector: deque iterator not dereferencable

  • momentc

    Can you post how you fixed this. I appear to be having the same problem using a queue structure, but from what I have read queues should be thread safe.
  • galg

    The ISO/IEC C++ Standard knows nothing about threads: it assumes all code it written in a single threaded environment. Therefore none of the containers in the C++ Standard are thread safe. So if you need to use such a container in a multithreaded application then you have to ensure that you use them in a thread safe manner.

  • Nedrum

    Ok, the problem is solved. it seems like another thread was trying to acces the vector at the same time. this is now solved. sorry for bothering
  • DummyJone

    thanks for the answer. however, that was my first thought... but as soon as it gave that error, i paused the app, and looked at the content of Servers, and found out that it had more then 4000 items in it....

    Weird thing is that i dont get the error anymore. but as soon as it occours, i'll post it


  • wpcheah

    Looks like the deque is empty, in which case calling front would result in undefined behavior.

  • Vector: deque iterator not dereferencable