473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Debug assertion failed! involving STL Vector

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;

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
1 4134
horace1
1,510 Expert 1GB
is the STL vector you are using thread safe? see this discussion about VC++
http://vcfaq.mvps.org/lang/8.htm

also if you are altering a vector contents it could invalidate the iterator
http://www.cprogramming.com/tutorial/stl/iterators.html
Mar 28 '07 #2

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

Similar topics

0
by: Chemix | last post by:
Hello people, I've developed a windows forms application with VC++.NET. The problem I have is the next: I run my application and all seems go OK, but passed a certain time (it can be hours or some...
2
by: SorceCode | last post by:
Hey guys, good old > Debug Assertion Failed! > File: dbgdel.cpp > Line: 47 > Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) Rears its ugly head agian! Ok heres what Im up to..
2
by: w3r3w0lf | last post by:
hello! can anyone explain this to me? I get a "debug assertion failed" msg after some time in my prog...: file fclose.c, stream!=null thanks!
1
by: Kapt. Boogschutter | last post by:
Does anyone know Why I'm getting this Error??? Debug Assertion Failed! File: daocore.cpp Line: 42 My code: CDaoDatabase dao; dao.Create("filename");
2
by: Arti Potnis | last post by:
Hi, I have an application with a function "myfunction" that opens a file and writes to it using fprintf. This application runs on a unix (sun solaris 5.8) system. I connect to this application...
2
by: marat | last post by:
I have a managed c++ function below that makes a call to an unmanaged c++ dll .. This function is called from a C# app, resulting in a "Debug Assertion Failed dbgdel.cpp Line 52 Expression:...
4
by: ellieong | last post by:
When i try to run my program, i get this error "debug assertion failed!" and it's caused by this file called "afxtempl.h" at line 262. isn't this header file provided by c++? so how can i get rid...
0
by: lawrence | last post by:
Hi, I made a MFC ActiveX with a CwinThread Class in VC ++. Then i used it on Visual basic. When i try to make an exe i got this error : Debug Assertion Failed! Program: C:\PROGRAM...
4
by: Mullai | last post by:
Hi , My program gives an error message like this Debug Assertion Failed! program:................ File: wincore.cpp Line: 958 Please can anyone help me out in this issue. I have to solve...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.