473,657 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Debug assertion failed! involving STL Vector

53 New Member
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
WaitForMultiple Objects( MAX_THREADS, Thread_H, TRUE, INFINITE);
}
Mar 28 '07 #1
1 4158
horace1
1,510 Recognized Expert Top Contributor
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.cprogrammin g.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
2020
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 minutes), then a dialog window opens with the title:Microsoft Visual C++ Debug Library, and the next error: Debug Assertion Failed! Program: name of my program File: dbgheap.c Line: 1132 Expression: _CrtIsValidHeadPointer(pUserData)
2
3913
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
3901
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
2752
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
17602
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 from a VB GUi on a windows 2000 system. The GUI invokes "myfunction". I get the following error:-
2
8378
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: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)" errir message. This happens on function exit, looks like related to destruction of some vector. Any ideas why ????
4
13560
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 of this problem. if i click ignore i can see the output, but how can i get rid of such an error msg?
0
2938
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 FILES\MICROSOFT VISUAL STUDIO\VB98\VB6.EXE File: cmdtarg.cpp Line: 52
4
9401
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 this bug immediately in my project.
0
8413
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8324
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.