Page 1 of 1

Visual C++ Debug Library Crash

Posted: Mon Jun 06, 2011 1:14 pm
by CountToInfinity
I've been getting this error when I try to create a new body.
Debug Error!

Program: [path to program here]

This appliation has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
If it matters, I'm creating bodies after time stepping has begun, when a sensor is 'triggered,' using the same function I use to create them before simulation has begun. This error shows up in both MS Visual Studio and Code::Blocks.

Is this a simple error of oversight, or something critically wrong?

Re: Visual C++ Debug Library Crash

Posted: Mon Jun 06, 2011 1:40 pm
by slembcke
You got me. I remember being really frustrated with Windows for that error before. Basically that's the catch-all error that Windows logs when any program crashes from a number of problems. That is not my error message.

Try running it in the debugger, that should tell you what the actual error was and where it happened.

Re: Visual C++ Debug Library Crash

Posted: Mon Jun 06, 2011 3:22 pm
by CountToInfinity
Right now Visual Studio won't let me step into Chipmunk functions.

But the problem was somewhere after the call on the line

bodyshape = cpSpaceAddShape( space, cpPolyShapeNew(body, 4, verts, cpvzero)) ;

Where verts is an array of 4 vertexes.


Last time I was able to step though it, cpPolyShapeNew returned just fine, but somewhere cpSpaceAddShape brought up the crash. I'll continue trying figure out exactly where it stops and maybe get WinDbg working for more useful data.

EDIT: Here's a not too useful picture of the call stack.

Re: Visual C++ Debug Library Crash

Posted: Mon Jun 06, 2011 4:38 pm
by slembcke
cpPolyShapeNew() throws assertions if you pass it bad data. Was there anything in the log about a concave polygon or a bad winding?

Re: Visual C++ Debug Library Crash

Posted: Mon Jun 06, 2011 6:03 pm
by CountToInfinity
I don't think so. Looking at the locals, the value of 'verts' is the same when I create a similar body before the time step.

Here's a picture of the data right before calling the cpSpaceAddShape line. The first three are of shapes that work, the last is the one called later that crashes.

Of note may be verts, which follows the same pattern of positive and negative as the other ones.

EDIT: Splitting up the call with cpPolyShapeNew() returning to a temporary variable shows it's returning a shape similar to that of the other ones.

Re: Visual C++ Debug Library Crash

Posted: Tue Jun 07, 2011 4:28 pm
by CountToInfinity
Double post because I found the problem.

To put it simply, I was calling cpSpaceAddShape() while it was stepping by sticking it in to the collision handle function.

That's all.