views:

44

answers:

3
+1  Q: 

A weird crash...

Hi,

I have a piece of code that runs in debug mode in VS2008, C++. The problem is that when I am debugging the code line by line, at a very weird point of the code, it crashes and says:

debug assertion faild. Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)

The crash point is on the first closed curly bracket (after mesh->edges[e].needsUpdate=false;) I don't understand why on a curly bracket? does that make sense to you guys?

Can anybody help me understanding what is going on..?

for(int e=0; e<mesh->edges.size(); e++)
{
    if(mesh->edges[e].valid && mesh->edges[e].v[0]>=0 && mesh->edges[e].v[1]>=0 &&
        mesh->points[mesh->edges[e].v[0]].writable && mesh->points[mesh->edges[e].v[1]].writable)
    {
        //update v_hat and its corresponding error
        DecEdge Current = DecEdge(e);
        pair<Point, float> ppf = computeVhat(e);
        Current.v_hat = ppf.first;
        Current.error = ppf.second;

        edgeSoup.push(Current);
        mesh->edges[e].needsUpdate=false;
    }
}
+1  A: 

In my experience, crashes that happen on a closing brace mean that the crash happened in a destructor that ran when the block went out of scope. I'd check what's happening in the destructors for DecEdge and Point.

Paul Kuliniewicz
A: 

Check if u have deleted any of the pointers that u have used. This can be a reason.

ckv
A: 

You have some libraries compiled in DEBUG mode and some in RELEASE mode.

Romain Hippeau