Hi,
I’m trying to deserialize a simple box object I exported from the 3ds max 2013 PhysX plugin, and everything seems to go fine, but then I get an access violation during some memory allocation thing in the PhysX worker thread.
Am I doing something wrong here?
PhysX SDK 3.2.2 on x86, VS 2012
PxPhysics* physics = gEngine->getPhysics()->getPhysics();
PxCooking* cooking = gEngine->getPhysics()->getCooking();
PxScene* scene = mWorld->getPhysical()->getScene();
PxCollection* buffers = physics->createCollection();
PxCollection* objects = physics->createCollection();
assert( scene != NULL && physics != NULL && cooking != NULL && buffers != NULL && objects != NULL );
PxDefaultFileInputData data( "dev_obj_test1.RepX" );
assert( data.isValid() );
assert( repx::deserializeFromRepX( data, *physics, *cooking, NULL, NULL, *buffers, *objects, NULL ) == repx::RepXErrorCode::eSuccess );
float nf = 40.0f;
physics->addCollection( *buffers, *scene );
physics->addCollection( *objects, *scene );
for ( PxU32 i = 0; i < objects->getNbObjects(); i++ ) {
PxActor* actor = objects->getObject( i )->is();
gEngine->getConsole()->printf( srcPhysics, L"Importing: %S", objects->getObject( i )->getConcreteTypeName() );
if ( actor && actor->isRigidDynamic() ) {
PxRigidDynamic* d = (PxRigidDynamic*)actor;
PxTransform pose( PxVec3( 0.0f, nf, 5.0f ) );
d->setGlobalPose( pose, true );
nf += 1.0f;
}
}
objects->release();
buffers->release();
I’ve tried not doing the posing loop, I’ve tried not releasing the collections, and I’ve tried not adding the buffers collection. I’ve also tried with both a convex mesh and a simple Box shape in the RepX, nothing matters. I get an access violation in the worker thread PxWorker00.
Call stack:
PhysX3_x86.dll!503c4d39() Unknown
PhysX3_x86.dll!503c9a72() Unknown
PhysX3_x86.dll!503c5ebd() Unknown
PhysX3_x86.dll!503c66ce() Unknown
PhysX3_x86.dll!503c6ad5() Unknown
PhysX3_x86.dll!503bb6eb() Unknown
kernel32.dll!_HeapFree@12() Unknown
> msvcr110d.dll!_unlock(int locknum) Line 366 C
Game.exe!physx::PxDefaultAllocator::allocate(unsigned int size, const char * __formal, const char * __formal, int __formal) Line 61 C++
PhysX3Common_x86.dll!50173b41() Unknown
PhysX3_x86.dll!503b8119() Unknown
PhysX3_x86.dll!503b8125() Unknown
PhysX3Common_x86.dll!50171b4e() Unknown
Game.exe!physx::Ext::CpuWorkerThread::execute(void) Unknown
The access violation happens in VCRT’s mlock.c function _lock, where it tries to compare data from a bad array index to null:
/*
* Create/open the lock, if necessary
*/
if ( _locktable[locknum].lock == NULL ) {
if ( !_mtinitlocknum(locknum) )
_amsg_exit( _RT_LOCK );
}
// locknum is 256, which is out of bounds for the array -> access violation