Hi, again i'm standing with a bit of a weird situation.
I''ve a queue holding some data and sometimes after a few minuts i get the error. deque iterator not dereferencable and the queue size is 0 while doing myclass* ptr = myqueue.front();

You might think, hey this is a just another guy dont knowing a bit about thread safety but thats not the case because:
Code:
			//////////////////////////
			///Implementations
			Pool* retrieveNextFillable(){
				AvailableFillerPools.Lock();
				Gameye::Library::Memory::CMemoryPool<Gameye::Games::NDServer>* temp = NULL;
				if (AvailableFillerPools.empty()){
					AvailableFillerPools.Unlock();
					return NULL;
				}
				temp = AvailableFillerPools.front();
				AvailableFillerPools.pop();
				AvailableFillerPools.Unlock();
				return temp;
			}
Lock and unlock are corresponding to a critical section wich works fine.
De declaration of the type of AvailableFillerPools is easy:
Code:
template <typename T> class CQueue : public CMemoryProtect, public std::queue<T>{};
My application is multithreader and yes, multiple threads are accesing the queue at the same time. however every function using the queue locks him first. better said, there is only 1 other method using the same queue at the same time, thats the return method:
Code:
			void returnNextFillable(Pool* item){
				if (item!=NULL){
					AvailableScannerPools.Lock();
					AvailableScannerPools.push(item);
					AvailableScannerPools.Unlock();
				}
				LevelMonitor.incFillPools();
			}
With multithreaded, i am talking about around the 50 threads doing the same thing and all are using the retrieve and return method

Does anyone knows whats going on here. clearly he should return at
Code:
				if (AvailableFillerPools.empty()){
					AvailableFillerPools.Unlock();
					return NULL;
				}
but for some or other reason he sometimes skips that part. and with sometimes i mean 1 at the 10000 or so

Thanks already!