Deadlock in GeomOverlapMulti_PhysX

Deadlock in GeomOverlapMulti_PhysX

We have been trying to get a helicopter up and working but myself and others are getting a deadlocking issue in the following file and function on the “PxI32 NumHits = SyncScene->overlapMultiple(…)” call:

D:\Unreal Engine\4.7\Engine\Source\Runtime\Engine\Private\Collision\PhysXCollision.cpp

#if WITH_PHYSX
bool GeomOverlapMulti_PhysX(const UWorld* World, const PxGeometry& PGeom, const PxTransform& PGeomPose, TArray<FOverlapResult>& OutOverlaps, ECollisionChannel TraceChannel, const struct FCollisionQueryParams& Params, const struct FCollisionResponseParams& ResponseParams, const struct FCollisionObjectQueryParams& ObjectParams)
{
    	SCOPE_CYCLE_COUNTER(STAT_Collision_GeomOverlapMultiple);
	bool bHaveBlockingHit = false;
	PxScene* LockedScenes[] = { nullptr, nullptr, nullptr };

	// overlapMultiple only supports sphere/capsule/box 
	if (PGeom.getType()==PxGeometryType::eSPHERE || PGeom.getType()==PxGeometryType::eCAPSULE || PGeom.getType()==PxGeometryType::eBOX || PGeom.getType()==PxGeometryType::eCONVEXMESH )
	{
		// Create filter data used to filter collisions
		PxFilterData PFilter = CreateQueryFilterData(TraceChannel, Params.bTraceComplex, ResponseParams.CollisionResponse, ObjectParams, true);
		PxSceneQueryFilterData PQueryFilterData(PFilter, PxSceneQueryFilterFlag::eSTATIC | PxSceneQueryFilterFlag::eDYNAMIC | PxSceneQueryFilterFlag::ePREFILTER);
		FPxQueryFilterCallback PQueryCallback(Params.IgnoreComponents);

		// Enable scene locks, in case they are required
		FPhysScene* PhysScene = World->GetPhysicsScene();
		PxScene* SyncScene = PhysScene->GetPhysXScene(PST_Sync);

		SCENE_LOCK_READ(SyncScene);		//we can't use scoped because we later do a conversion which depends on these results and it should all be atomic
		LockedScenes[PST_Sync] = SyncScene;

		// Create buffer for hits. Note: memory is not initialized (for perf reasons), since API does not require it.
		TTypeCompatibleBytes<PxOverlapHit> RawPOverlapArray[OVERLAP_BUFFER_SIZE];
		PxOverlapHit* POverlapArray = (PxOverlapHit*)RawPOverlapArray;

		PxI32 NumHits = SyncScene->overlapMultiple(PGeom, PGeomPose, POverlapArray,  OVERLAP_BUFFER_SIZE_MAX_SYNC_QUERIES, PQueryFilterData, &PQueryCallback);

The last line is where it stops. The audio continues but the game and render threads seem to be stuck and the game freezes while in the editor.

Here is the complete stack trace and it is repeatable and occurs within a few minutes of our project.

PhysX3CommonPROFILE_x64.dll!000007fed378de9b()	Unknown
PhysX3CommonPROFILE_x64.dll!000007fed378d519()	Unknown
PhysX3CommonPROFILE_x64.dll!000007fed37289aa()	Unknown
PhysX3CommonPROFILE_x64.dll!000007fed37c33c2()	Unknown
PhysX3CommonPROFILE_x64.dll!000007fed385718d()	Unknown
PhysX3CommonPROFILE_x64.dll!000007fed385a3d9()	Unknown
PhysX3PROFILE_x64.dll!000007fed33d04a0()	Unknown
PhysX3PROFILE_x64.dll!000007fed3590226()	Unknown
PhysX3PROFILE_x64.dll!000007fed358dfd0()	Unknown
PhysX3PROFILE_x64.dll!000007fed33cbd23()	Unknown
UE4Editor-Engine.dll!GeomOverlapMulti_PhysX(const UWorld * World, const physx::PxGeometry & PGeom, const physx::PxTransform & PGeomPose, TArray<FOverlapResult,FDefaultAllocator> & OutOverlaps, ECollisionChannel TraceChannel, const FCollisionQueryParams & Params, const FCollisionResponseParams & ResponseParams, const FCollisionObjectQueryParams & ObjectParams) Line 1627	C++
UE4Editor-Engine.dll!FBodyInstance::OverlapMulti(TArray<FOverlapResult,FDefaultAllocator> & InOutOverlaps, const UWorld * World, const FTransform * pWorldToComponent, const FVector & Pos, const FRotator & Rot, ECollisionChannel TestChannel, const FComponentQueryParams & Params, const FCollisionResponseParams & ResponseParams, const FCollisionObjectQueryParams & ObjectQueryParams) Line 3721	C++
UE4Editor-Engine.dll!USkeletalMeshComponent::ComponentOverlapMulti(TArray<FOverlapResult,FDefaultAllocator> & OutOverlaps, const UWorld * World, const FVector & Pos, const FRotator & Rot, ECollisionChannel TestChannel, const FComponentQueryParams & Params, const FCollisionObjectQueryParams & ObjectQueryParams) Line 1886	C++
UE4Editor-Engine.dll!UWorld::ComponentOverlapMulti(TArray<FOverlapResult,FDefaultAllocator> & OutOverlaps, const UPrimitiveComponent * PrimComp, const FVector & Pos, const FRotator & Rot, const FComponentQueryParams & Params, const FCollisionObjectQueryParams & ObjectQueryParams) Line 401	C++
UE4Editor-Engine.dll!UPrimitiveComponent::UpdateOverlaps(const TArray<FOverlapInfo,FDefaultAllocator> * PendingOverlaps, bool bDoNotifies, const TArray<FOverlapInfo,FDefaultAllocator> * OverlapsAtEndLocation) Line 2256	C++
UE4Editor-Engine.dll!UPrimitiveComponent::MoveComponent(const FVector & Delta, const FRotator & NewRotation, bool bSweep, FHitResult * OutHit, EMoveComponentFlags MoveFlags) Line 1600	C++
UE4Editor-Engine.dll!UPrimitiveComponent::SyncComponentToRBPhysics() Line 557	C++
UE4Editor-Engine.dll!USkeletalMeshComponent::PreClothTick(float DeltaTime) Line 3087	C++
UE4Editor-Engine.dll!FTickTaskSequencer::FTickFunctionTask::DoTask(ENamedThreads::Type CurrentThread, const TRefCountPtr<FGraphEvent> & MyCompletionGraphEvent) Line 322	C++
UE4Editor-Engine.dll!TGraphTask<FTickTaskSequencer::FTickFunctionTask>::ExecuteTask(TArray<FBaseGraphTask *,FDefaultAllocator> & NewTasks, ENamedThreads::Type CurrentThread) Line 671	C++
UE4Editor-Core.dll!FTaskThread::ProcessTasks(int QueueIndex, bool bAllowStall) Line 428	C++
UE4Editor-Core.dll!FTaskThread::ProcessTasksUntilQuit(int QueueIndex) Line 271	C++
UE4Editor-Core.dll!FTaskGraphImplementation::WaitUntilTasksComplete(const TArray<TRefCountPtr<FGraphEvent>,TInlineAllocator<4,FDefaultAllocator> > & Tasks, ENamedThreads::Type CurrentThreadIfKnown) Line 984	C++
UE4Editor-Engine.dll!FTaskGraphInterface::WaitUntilTaskCompletes(const TRefCountPtr<FGraphEvent> & Task, ENamedThreads::Type CurrentThreadIfKnown) Line 188	C++
UE4Editor-Engine.dll!FTickTaskSequencer::ReleaseTickGroup(ETickingGroup WorldTickGroup, bool bBlockTillComplete) Line 187	C++
UE4Editor-Engine.dll!FTickTaskManager::RunTickGroup(ETickingGroup Group, bool bBlockTillComplete) Line 722	C++
UE4Editor-Engine.dll!UWorld::RunTickGroup(ETickingGroup Group, bool bBlockTillComplete) Line 696	C++
UE4Editor-Engine.dll!UWorld::Tick(ELevelTick TickType, float DeltaSeconds) Line 1126	C++
UE4Editor-UnrealEd.dll!UEditorEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 1329	C++
UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 347	C++
UE4Editor.exe!FEngineLoop::Tick() Line 2257	C++
UE4Editor.exe!GuardedMain(const wchar_t * CmdLine, HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, int nCmdShow) Line 142	C++
UE4Editor.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow) Line 191	C++
[External Code]	

I have a sample project that I can provide (privately) to an Epic dev to investigate this issue as it has occurred every time within a few minutes of running this project.

Please e-mail me directly and I will send you the drop box link for the project.
Thanks!

I should add that this is the screenshot from our other guy’s screen as well showing the exact same spot and issue.

http://i.imgur.com/mVcN8UR.png

I’m pretty sure it has to do with the boxes on the helicopter’s physics asset. It seems that it only occurs when we use boxes for the landing skids. It also has only occurred when we are airborne. It does not occur if I leave it sitting on the ground without any inputs.

Hi ,

If you have a sample project showing this issue on Dropbox, you can [send me a private message][1] on the forums with a link.

You mentioned that this only seems to happen when using boxes for the landing skids of your helicopter. Have you tried using something else, such as a capsule, and seen the same results?

PM sent. We have only noticed the issue when using boxes.

Thanks for providing the sample project. I spent the last hour or so experimenting with it. I was able to get the Editor to hang like you described, though it seems to be somewhat random. Sometimes it happened nearly immediately, sometimes it took several minutes, sometimes it didn’t happen at all (or I just lost patience before it happened). I have not had any luck so far pinpointing why the hang is happening, but I plan on digging into it some more Monday morning.

Yeah, like I said, it has never occurred just letting it sit on the ground but only when flying with boxes in the Physics for the skids. If you remove the boxes and replace them with something else then it has never occurred to me. But even if I provide the project to others with no boxes and then they replace them with boxes then it will freeze on them. So it has something to do with using boxes on the Physics asset. Anyhow, I’m sure you are having a bit of fun flying it around.
Thanks ,

Hi ,

I looked into this issue some more today, but was unable to determine what may be causing the Editor to become unresponsive. However, I went ahead and filed a report of what I observed to have this further investigated (UE-13035).

Any progress on this issue? Where can we check the status as our helicopter is pretty much on hold because of this issue.
Thanks,

Hi ,

I checked the status of the report that I had entered for this issue, and the status is still set as “To Do”. We do not currently have a way for you to check the status yourself, but there has been some talk internally about finding a way to make that information public.

I did spend some more time testing this today. After converting your project to our latest internal version of the Engine (after 4.8 was branched), I spent some time with the helicopter and did not see the hang occur. I realize the issue is somewhat random, so I am not yet confident enough to say that the issue has gone away. What is the latest version of the Engine in which you have seen this hang occur?

4.7.5/4.7.6 - perhaps I can test it with 4.8 preview and update you. Thank !

Try merge this commit:

https://github.com/EpicGames/UnrealEngine/commit/4f095dc855b0a5f08376ecb678601ed5a6cd62f2

I believe it may helps you.

I was testing it quite a bit last night and it never froze up on me. So I guess we can say that that January commit fixed this issue. I’ll update this post if I find out otherwise.
Thanks !

I wanted to mention that I hit this today. In my case it was user error, I was accidentally spawning endless numbers of 1 collider type inside of another collider type due to not setting my flag before the creation loop.

We’ve been seeing this exact lockup lately in 4.11. Seems to happen randomly, sometimes immediately on play, sometimes after playing for a while, sometimes not at all. Definitely happening on the NumHits = SyncScene->overlapMultiple() call in PhysXCollision though.

Hi sbounds,

Unfortunately this is not something that we have been able to reproduce in any internal projects. The only time we were able to reproduce it here was with a supplied by , and those occurrences were also completely random. Unfortunately we reached a point where we were no longer able to reproduce the issue in the (I believe in the commit mentioned above, but I am not sure this was actually what fixed the issue), and determined that it had been corrected. If you have a that is still exhibiting this behavior, would it be possible to get that project so we can take a look?