473,245 Members | 1,796 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,245 software developers and data experts.

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 8310
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
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..
6
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
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
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...
2
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
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:...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...

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.