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

Debug Assertion Failed dbgdel.cpp error

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.