By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,693 Members | 1,132 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,693 IT Pros & Developers. It's quick & easy.

Debug assertion failed! involving STL Vector

P: 53
im running code thats using threads, everytime i get this debug assertion failed box poping up.

It involves with my stl vector.

its saying that vector iterators incompatible.

the vector contains structs of data.
i have ten threads running, using the same function called "GetMemory()".
the function just looks through the function and swaps around the data in the vector list. The first ten containers in the vector are the Main Memory, and the rest of the vector list is virtual memory.

Also before it calls "GetMemory()" function it calls another function which intilise the vector with so many structs

so far its like this :

typedef struct{

int page_number;
int thread number;
int used;

DATA ThreadData[10] // initilised in another function

vector<struct> memory;

GetMemory( ThreadData[], int number )
// checks through the virtual memory

for( iter = memory.begin() + 10; iter != memory.end(); ++iter )
if( iter->page_number == ThreadData[ number ].page_number
&& iter -> Thread_Number == Number )
// does stuff in here

thats the first part of the code in the fucntion so far, is there any amatuer errors there? not a total expert in stl vectors or using thread command fucntion

main function()
create ten threads
WaitForMultipleObjects( MAX_THREADS, Thread_H, TRUE, INFINITE);
Mar 28 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,510
is the STL vector you are using thread safe? see this discussion about VC++

also if you are altering a vector contents it could invalidate the iterator
Mar 28 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.