473,511 Members | 14,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Debug Assertion Failed dbgdel.cpp error

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 ????
ArrayList*
NM::doSomething(ArrayList* anchorStrikesList,
ArrayList* anchorVolsList,
ArrayList* allStrikesList

{
vector<double> anchorStrikesVec, anchorVolsVec, allStrikesVec, allVolsVec;

////// convert to vectors ////

for (int i = 0; i < anchorStrikesList->Count; ++i)
{
double val = *dynamic_cast<double __gc *>(anchorStrikesList->get_Item(i));
anchorStrikesVec.push_back(val);
}
for (i = 0; i < anchorVolsList->Count; ++i)
{
double val = *dynamic_cast<double __gc *>(anchorVolsList->get_Item(i));
anchorVolsVec.push_back(val);
}
for (i = 0; i < allStrikesList->Count; ++i)
{
double val = *dynamic_cast<double __gc *>(allStrikesList->get_Item(i));
allStrikesVec.push_back(val);
}

// unmanaged c++ dll call
foo(anchorStrikesVec, anchorVolsVec, allStrikesVec, allVolsVec);

// Convert back to vector of computed vols and return
ArrayList* allVolsList = new ArrayList();
for (i = 0; i < allVolsVec.size(); ++i)
{
double vol = allVolsVec[i];
allVolsList->Add(__box(vol));
}
return allVolsList;

}
Nov 16 '05 #1
2 8339
Surely someone must have had experience with this one ?

mr******@yahoo.com (marat) wrote in message news:<fc**************************@posting.google. com>...
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)" error message.

This happens on function exit, looks like related to destruction of some vector.

Any ideas why ????
ArrayList*
NM::doSomething(ArrayList* anchorStrikesList,
ArrayList* anchorVolsList,
ArrayList* allStrikesList

{
vector<double> anchorStrikesVec, anchorVolsVec, allStrikesVec, allVolsVec;

////// convert to vectors ////

for (int i = 0; i < anchorStrikesList->Count; ++i)
{
double val = *dynamic_cast<double __gc *>(anchorStrikesList->get_Item(i));
anchorStrikesVec.push_back(val);
}
for (i = 0; i < anchorVolsList->Count; ++i)
{
double val = *dynamic_cast<double __gc *>(anchorVolsList->get_Item(i));
anchorVolsVec.push_back(val);
}
for (i = 0; i < allStrikesList->Count; ++i)
{
double val = *dynamic_cast<double __gc *>(allStrikesList->get_Item(i));
allStrikesVec.push_back(val);
}

// unmanaged c++ dll call
foo(anchorStrikesVec, anchorVolsVec, allStrikesVec, allVolsVec);

// Convert back to vector of computed vols and return
ArrayList* allVolsList = new ArrayList();
for (i = 0; i < allVolsVec.size(); ++i)
{
double vol = allVolsVec[i];
allVolsList->Add(__box(vol));
}
return allVolsList;

}

Nov 16 '05 #2
The problem appears to occur due to the unmanaged foo() call's last
argument which is a non const reference to a vector.

The prototype of foo is :

void foo(const vector<double>& l1,
const vector<double>& l2,
const vector<double>& l3,
vector<double>& result);

If result vector is empty, no problem occurs.
If non-empty then the below error occurs.

The last argument needs to be non const.

Anyone know how to solve this one ?


ArrayList*
NM::doSomething(ArrayList* anchorStrikesList,
ArrayList* anchorVolsList,
ArrayList* allStrikesList

{
vector<double> anchorStrikesVec, anchorVolsVec, allStrikesVec, allVolsVec;

////// convert to vectors ////

for (int i = 0; i < anchorStrikesList->Count; ++i)
{
double val = *dynamic_cast<double __gc *>(anchorStrikesList->get_Item(i));
anchorStrikesVec.push_back(val);
}
for (i = 0; i < anchorVolsList->Count; ++i)
{
double val = *dynamic_cast<double __gc *>(anchorVolsList->get_Item(i));
anchorVolsVec.push_back(val);
}
for (i = 0; i < allStrikesList->Count; ++i)
{
double val = *dynamic_cast<double __gc *>(allStrikesList->get_Item(i));
allStrikesVec.push_back(val);
}

// unmanaged c++ dll call
foo(anchorStrikesVec, anchorVolsVec, allStrikesVec, allVolsVec);

// Convert back to vector of computed vols and return
ArrayList* allVolsList = new ArrayList();
for (i = 0; i < allVolsVec.size(); ++i)
{
double vol = allVolsVec[i];
allVolsList->Add(__box(vol));
}
return allVolsList;

}

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2002
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
3903
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..
6
595
by: Cormac | last post by:
Hi everyone, I'm writing Pure Data externals in C++ using Ms Visual C++ 7.0 and Windows2000. I'm running motions sensor hardware so there's a bit of real time data processing involved. When...
2
17585
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...
4
13549
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
2903
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
9375
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...
2
5550
by: Pushpa | last post by:
Hi All, This my part of the c++ program using threads in windows : //modified by pushpa struct structExrdDoc { CExrdDoc* spDoc; LPCTSTR sstrFileName;
0
1849
by: =?Utf-8?B?REx1ZWNr?= | last post by:
I am getting a debug assertion error that reads: Debug Assertion Failed! program E:\program files\internet explorer\iexplore,exe File: dbgheap.c Line: 1252 Expression:...
0
7349
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
7417
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...
1
7074
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
5659
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
3219
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...
0
3210
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
445
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...

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.