Crash when simulating vehicles

Crash when simulating vehicles

Hi, I am getting the message "PNGRacer.exe has triggered a breakpoint" when running using the debug libraries. This is the call stack:

 	PNGRacer.exe!hkRigidMotionUtilBuildAccumulators(const hkStepInfo & info, hkpMotion * const * motions, int numMotions, int motionOffset, hkpVelocityAccumulator * accumulatorsOut)  Line 320 + 0xce bytes	C++

 	PNGRacer.exe!hkpVehicleInstance::prepareChassisParams(const hkStepInfo & stepInfo, hkpVehicleFrictionSolverParams & frictionParams)  Line 624 + 0x1b bytes	C++

 	PNGRacer.exe!hkpVehicleInstance::simulateVehicle(const hkStepInfo & stepInfo, const hkpVehicleAerodynamics::AerodynamicsDragOutput & aerodynamicsDragInfo, const hkArray & suspensionForceAtWheel, const hkArray & totalLinearForceAtWheel, hkpVehicleJobResults & vehicleResults)  Line 892	C++

 	PNGRacer.exe!hkpVehicleInstance::stepVehicleUsingWheelCollideOutput(const hkStepInfo & stepInfo, const hkpVehicleWheelCollide::CollisionDetectionWheelOutput * cdInfo, hkpVehicleJobResults & vehicleResults)  Line 966	C++

 	PNGRacer.exe!hkpVehicleInstance::stepVehicle(const hkStepInfo & stepInfo)  Line 986	C++

>	PNGRacer.exe!HavokController::runSimulation(float interval)  Line 420	C++

Here, I call stepVehicle directly. The error occurs on the second frame.I get similar results when I use a (non-batching) vehicle manager, on the second frame:
 	PNGRacer.exe!hkRigidMotionUtilBuildAccumulators(const hkStepInfo & info, hkpMotion * const * motions, int numMotions, int motionOffset, hkpVelocityAccumulator * accumulatorsOut)  Line 320 + 0xce bytes	C++

 	PNGRacer.exe!hkpVehicleInstance::prepareChassisParams(const hkStepInfo & stepInfo, hkpVehicleFrictionSolverParams & frictionParams)  Line 624 + 0x1b bytes	C++

 	PNGRacer.exe!hkpVehicleInstance::simulateVehicle(const hkStepInfo & stepInfo, const hkpVehicleAerodynamics::AerodynamicsDragOutput & aerodynamicsDragInfo, const hkArray & suspensionForceAtWheel, const hkArray & totalLinearForceAtWheel, hkpVehicleJobResults & vehicleResults)  Line 892	C++

 	PNGRacer.exe!hkpVehicleManager::stepVehicleArray(hkArray & activeVehicles, const hkStepInfo & updatedStepInfo)  Line 82	C++

 	PNGRacer.exe!hkpVehicleManager::stepVehicles(const hkStepInfo & updatedStepInfo)  Line 49 + 0xd bytes	C++

>	PNGRacer.exe!HavokController::runSimulation(float interval)  Line 426	C++

I tried to take a snapshot of the world but I got another breakpoint:
 	PNGRacer.exe!checkObject(const void * o, const hkClass * k)  Line 25 + 0xa0 bytes	C++

 	PNGRacer.exe!hkRefVariant::set(void * o, const hkClass * k)  Line 47	C++

 	PNGRacer.exe!hkpHavokSnapshot::saveUnderRootLevel(const void * data, const hkClass & dataClass, hkStreamWriter * writer, hkpHavokSnapshot::Options outputOptions, const hkStructureLayout::LayoutRules * targetLayout)  Line 164 + 0x73 bytes	C++

 	PNGRacer.exe!hkpHavokSnapshot::save(const hkpPhysicsData * data, hkStreamWriter * writer, hkpHavokSnapshot::Options outputOptions, const hkStructureLayout::LayoutRules * targetLayout)  Line 157 + 0x1f bytes	C++

 	PNGRacer.exe!hkpHavokSnapshot::save(const hkpWorld * world, hkStreamWriter * writer, hkpHavokSnapshot::Options outputOptions, const hkStructureLayout::LayoutRules * targetLayout, bool saveContactPoints)  Line 147 + 0x16 bytes	C++

>	PNGRacer.exe!HavokController::runSimulation(float interval)  Line 421 + 0x2a bytes	C++

How can I debug the snapshot problem so that I can provide one for this thread? I have the non-licensed version, so the source code isn't available to me.

8 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

Hey ihcn,

What kind of console output are you getting when these
breakpoints are triggered? If you've set up errorReport to print to stdout you
should see a brief description whenever you fail an assert. Knowing which
assert you are hitting in hkRigidMotionUtilBuildAccumulators and checkObject
will shed some light on what the problem may be.

-Nick

Nick S. Developer Support Engineer Havok www.havok.com

Hi, thanks for responding. I had an errorReport function that was using printf, but my windowing system was suppressing the output and I didn't realize it, so i just assumed that the asserts didn't give any useful info. I changed some things around and now I see the output.My error when trying to take a snapshot is the following:

Types\hkRefVariant.cpp(25): [0x204578F6] Assert: realClassObject at 0x038E2C20 is not reference counted or 'hkpPhysicsData' is not registered.hkRefVariant can be used with reference counted objects only.Types\hkRefVariant.cpp(25): [0x204578F6] Assert: realClassObject at 0x038E2C20 is not reference counted or 'hkpPhysicsData' is not registered.hkRefVariant can be used with reference counted objects only.

I changed my calling code a little to the following:

hkStdioStreamWriter *wr = new hkStdioStreamWriter("output.xml");

hkpPhysicsData *data = new hkpPhysicsData();

data->populateFromWorld(m_world.get());

hkpHavokSnapshot::save(data,wr);

wr->close();

delete wr;
With this code, I can confirm that the memory address the assert is giving (0x038E2C20) is that of the hkpPhysicsData stored in the "system" variable. I don't understand the error, why wouldn't it be reference counted?

Hey ichcn,

In the code snippet your provided, are you making sure to
callm_world->markForWrite() and m_world->unmarkForWrite() around your
populateFromWorld() and save()? Also have you tried the example code for taking
a snapshot from the Havok docs? It can be found at:

Common Havok Components -> Serialization ->
Serialization and Physics -> Snapshot Utility

The example is very straightforward. If you haven't done so
try it and see if you get the same error message.

Lastly, what are the error messages you are getting when the
breakpoint in hkRigidMotionUtilBuildAccumulators() is hit?

-Nick

Nick S. Developer Support Engineer Havok www.havok.com

I tried copy/pasting the example and including the changes you suggested:

        m_world->markForWrite();
	hkOstream outfile( "output.xml" );

	hkpHavokSnapshot::save(m_world.get(), outfile.getStreamWriter(), false);
	m_world->unmarkForWrite();
It has the same error as before.For the build accumulators error, from what I can tell in the ouput, the error is
Y:\Build\20120405_200003_PcXsPerpetualKeycode\Source\Common/Base/Math/SweptTransform/hkSweptTransform.inl(27): [0xF0FF0080] Assert: Disable this assert if it gets fired from your user code. It is only used to check internal consistency.

I'm not sure how to disable it though, and even if I did, when I run the release build (thus bypassing all of the asserts), the vehicles behave very erratically, so it seems like it's not just a matter of turning some switch off to ignore the assert.

Hey ihcn,

Sorry for the delayed response, I have a few suggestions for
you.

First, it seems your code for taking a snapshot isn't
working correctly because it cannot successfully generate a hkpPhysicsData from
your hkpWorld. Try moving your snapshot code to directly after you create your
hkpWorld and see if you still get the same assert. If you can successfully take
a snapshot you know somewhere between your hkpWorld creation and where you were
previously trying to take a snapshot something is potentially
breaking/corrupting your physics world.

Next, it looks like the asserts you are hitting in
hkRigidMotionUtilBuildAccumulators are due to the size of your timestep. The
assert is being fired when the accumulator is trying to interpolate the center
of mass of the vehicle's rigid bodies. The integration step's start time is
outside the bounds of the interpolation, mostly likely caused by too large a
timestep. What size is your timestep?

-Nick

Nick S. Developer Support Engineer Havok www.havok.com

Hi, I moved the code to take a snapshot directly after creating my world and the crash still occurs, so the problem happens before I have the opportunity to corrupt it.

m_world = std::shared_ptr(new hkpWorld( info ));
m_world->markForWrite();
hkOstream outfile( "output.xml" );

hkpHavokSnapshot::save(m_world.get(), outfile.getStreamWriter(), false);
m_world->unmarkForWrite();
As for the other problem, this is my code for simulating the vehicles and the world:
//do vehicle stuff

hkStepInfo i;

i.m_deltaTime = interval;

i.m_invDeltaTime = 1/interval;
m_vehicleManager->stepVehicles(i);
//simulate the world

m_world->stepDeltaTime(interval);
Interval is 0.1, and i have confirmed by inserting debug output statements that right before m_vehicleManager->stepVehicles(i) is called, i.m_deltaTime is 0.1, and i.m_invDeltaTime is 100

Hi ihcn,

A few quick comments. First, you no longer need to mark and
unmark the hkpWorld for write with your new snapshot code, as that version of
hkpHavokSnapshot::save() does that internally.

Second, I would not use std::shared_ptr to manage pointers
to hkReferencedObjects (in this case, your hkpWorld). Our SDK uses
hkReferencedObjects, a subclass of hkBaseObjects, as the base class for objects
that can have multiple owners. You can read more about hkReferencedObjects in:

Common Havok Components -> Base Library -> The Base
System -> Reference Counting

Providing an additional layer of reference tracking is
unnecessary, and may introduce issues, so I suggest removing it and see if that
removes the issue with taking a snapshot.

In regards to your code for simulating the vehicles, your
interval is 0.1 secs, but your debugging output is displaying a deltaTime of
0.1 secs with an invDeltaTime of 100 1/sec? If that is the case your
invDeltaTime is incorrect as it should be 10 1/sec.

Do I understand this correctly?

-Nick

Nick S. Developer Support Engineer Havok www.havok.com

Kommentar hinterlassen

Bitte anmelden, um einen Kommentar hinzuzufügen. Sie sind noch nicht Mitglied? Jetzt teilnehmen