Crash on six consecutive (PhysX3DEBUG_x64) physx::PxCreateSpatialIndex

I’m making a Unity plugin to integrate some components of Nvidia Blast, and I’m running into trouble when initializing PhysX through the plugin. Essentially I’m using the same initialization code in the initPhysX method in Nvidia Blasts’s Authoring application:

gFoundation = PxCreateFoundation(PX_FOUNDATION_VERSION, NvBlastGetPxAllocatorCallback(), NvBlastGetPxErrorCallback());
if(!gFoundation) {
	return false;
physx::PxTolerancesScale scale;
gPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *gFoundation, scale, true);
if(!gPhysics) {
	return false;
physx::PxCookingParams cookingParams(scale);
cookingParams.buildGPUData = true;
gCooking = PxCreateCooking(PX_PHYSICS_VERSION, gPhysics->getFoundation(), cookingParams);
if(!gCooking) {
	return false;
return true;

Here is the relavent stacktrace when it crashes (in Unity as a native plugin):

0x00007FFF4F543FB8 (KERNELBASE) RaiseException
0x00007FFEF1B1232C (PhysX3DEBUG_x64) physx::PxCreateSpatialIndex
0x00007FFEF1B10710 (PhysX3DEBUG_x64) physx::PxCreateSpatialIndex
0x00007FFEF17BECC4 (PhysX3DEBUG_x64) physx::PxCreateSpatialIndex
0x00007FFEF17BF60D (PhysX3DEBUG_x64) physx::PxCreateSpatialIndex
0x00007FFEF17E8B31 (PhysX3DEBUG_x64) physx::PxCreateSpatialIndex
0x00007FFEF17E81BA (PhysX3DEBUG_x64) physx::PxCreateSpatialIndex
0x00007FFF22B92A05 (Fractre) [c:\nvidia\packman-repo\physx-vc14win64\3.4.23426887\physx_3.4\include\pxphysics.h:828] PxCreatePhysics 
0x00007FFF22B93209 (Fractre) [c:\users\jesse\documents\github\blast\compiler\fractre\fractre.cpp:53] Initialize 
0x0000000038A7155E (Mono JIT Code) (wrapper managed-to-native) JesseStiller.FractrePlugin.Fractre:Initialize ()
0x0000000038A702C3 (Mono JIT Code) [C:\Users\Jesse\Documents\GitHub\MarbleDepths\Assets\Fractre\Editor\FractreWindow.cs:68] JesseStiller.FractrePlugin.FractreWindow:OnEnable ()

Any ideas what must be going on? For all I can see I am initializing everything the same way the Blast authoring app, so I am not sure what’s wrong.

Okay, I’ve been able to debug it properly with the debug symbols and it seems to crash on calling GuMeshFactory() on line 57 of NpFactory.cpp. For whatever reason now it’s telling me “Module not found”, so in theory all I have to do is copy over the .dll for NpFactory?

The errors logged while debugging:

Exception thrown at 0x00007FFF4F543FB8 (KernelBase.dll) in Unity.exe: 0xC06D007E: Module not found (parameters: 0x00000000005FC5D0).
Unhandled exception at 0x00007FFF4F543FB8 (KernelBase.dll) in Unity.exe: 0xC06D007E: Module not found (parameters: 0x00000000005FC5D0).

Here’s what Unity outputs on the crash:

0x00007FFF4F543FB8 (KERNELBASE) RaiseException
0x00007FFEF0840835 (PhysX3DEBUG_x64) [f:\dd\vctools\delayimp\delayhlp.cpp:323] __delayLoadHelper2 
0x00007FFEF0669011 (PhysX3DEBUG_x64) _tailMerge_physx3commondebug_x64_dll
0x00007FFEF051CDA4 (PhysX3DEBUG_x64) [c:\users\jesse\documents\github\physx-3.4\physx_3.4\source\physx\src\npfactory.cpp:67] physx::NpFactory::NpFactory 
0x00007FFEF051D6ED (PhysX3DEBUG_x64) [c:\users\jesse\documents\github\physx-3.4\physx_3.4\source\physx\src\npfactory.cpp:122] physx::NpFactory::createInstance 
0x00007FFEF0545721 (PhysX3DEBUG_x64) [c:\users\jesse\documents\github\physx-3.4\physx_3.4\source\physx\src\npphysics.cpp:269] physx::NpPhysics::createInstance 
0x00007FFEF0544DAA (PhysX3DEBUG_x64) [c:\users\jesse\documents\github\physx-3.4\physx_3.4\source\physx\src\npphysics.cpp:831] PxCreateBasePhysics


Did you managed to solve the crash by adding the PhysX DLLs?

Hi Sheikh, I forgot to come back to the topic to say that I’ve fixed the issue. Windows was in charge of finding the PhysX3CommonDEBUG_x64.dll, and I simply had to put the dll in a place where Windows typically searches for dlls.

Glad you got it fixed. Usually, the PhysX binaries to be loaded should be in the same folder as the application/plugin.