Frequent crashes in SetHitResultFromShapeAndFaceIndex

After migration to 4.18 we are experiencing frequent crashes in SetHitResultFromShapeAndFaceIndex as a result of calls to LineTraceSingleByChannel from our code. The same game codebase runs fine on 4.17.2.

The crash happens in release 4.18.0 as well as latest code from 4.18 branch (as built on 02.11.2017) - the stack trace provided is from the latter.

The parameters passed in the LineTraceSingleByChannel are valid.

In the exception point OwningComponent is nullptr.

BlahGame.exe!SetHitResultFromShapeAndFaceIndex(const physx::PxShape * PShape, const physx::PxRigidActor * PActor, const unsigned int FaceIndex, FHitResult & OutResult, bool bReturnPhysMat) Line 379

BlahGame.exe!ConvertQueryImpactHit(const UWorld * World, const physx::PxLocationHit & PHit, FHitResult & OutResult, float CheckLength, const physx::PxFilterData & QueryFilter, const FVector & StartLoc, const FVector & EndLoc, const physx::PxGeometry * const Geom, const physx::PxTransform & QueryTM, bool bReturnFaceIndex, bool bReturnPhysMat) Line 51

BlahGame.exe!RaycastSingle(const UWorld * World, FHitResult & OutHit, const FVector Start, const FVector End, ECollisionChannel TraceChannel, const FCollisionQueryParams & Params, const FCollisionResponseParams & ResponseParams, const FCollisionObjectQueryParams & ObjectParams) Line 589

BlahGame.exe!UWorld::LineTraceSingleByChannel(FHitResult & OutHit, const FVector & Start, const FVector & End, ECollisionChannel TraceChannel, const FCollisionQueryParams & Params, const FCollisionResponseParams & ResponseParam) Line 87

link text

Hello,

Does this happen with particular assets? As in, does it only happen when the line trace hits certain actors? Are you able to reproduce this in a fresh project? If so, could you provide reproduction steps? If not, can you try running through the crash using a debugger, preferably setting a break point on the line trace itself and stepping into the start of SetHitResultFromShapeAndFaceIndex and seeing where the NULL appears? On the line before the crash, OwningComponent is supposed to be set to CustomPayload->GetOwningComponent().Get(); but it seems like that may be what is returning NULL.

Hi,
This seems to be related to destructible mesh - so far happens only when CustomPayload->OwningComponent is UDestructibleComponent.

The situation is as follows:

  • CustomPayload->OwningComponent seems to be ok, pointing to a valid component in the scene.
  • though the call CustomPayload->GetOwningComponent().Get() returns nullptr
  • it seems that FWeakObjectPtr::Internal_IsValid returns false, though I couldn’t find which of the conditions failes - this is inline code, tried to follow in assembly and for sure it’s not the first 3 conditions, then I lose track a bit :slight_smile:

Hopefully that helps.

One more detail - so far the crash happened only on a client in networked play.

This seems to require a particular setup, after your mention of destructibles and it only happening on a client. Would it be possible for you to provide a reproduction project?

I’m afraid I won’t find time to prepare a fresh project for that anytime soon, though I can help in testing any candidate fixes.

We are seeing this too, not on a client, but with destructibles.

The reason CustomPayload->GetOwningComponent().Get() fails in the case I’m seeing is because the owning component is pending kill.

We also are experiencing another PhysX-related 4.18 crash which occurs because there is now a large delay between fetchResults and further processing of those results for async scene actors, during which time the destructible actors may be destroyed. This seems suspiciously similar enough to likely be related, but I haven’t yet had time to track down exactly how.

Great! Looking forward a fix…

I changed my code to have if (OwningComponent) {} around the code and now it works. I’m not sure if it will harm anything though.

Unfortunately, without a reproduction of some sort, I cannot place a bug in for the issue and there will not be a fix entered for it. You may be able to use the workaround provided by poke1103 but if you are unable to assist with reproducing this issue, we will not be able to proceed.

I’m able to reproduce it: https://drive.google.com/open?id=1LKrC-3xFgBAw_smrLBdwWsmzhOdbdrKT

Hello Phyronnaz,

Thank you for that reproduction case. I reproduced the issue in 4.18.2 but it seems that this has already been fixed in our latest internal version, so I will not be entering a bug report for this, as that fix will likely be present in 4.19.

Have a nice day!

No: 4.18.3 Hotfix Released - Announcements - Unreal Engine Forums

I’m having the problem too. Was it fixed in 4.18.3?

You worked around it Phyronnaz?

So what’s the status? Has this issue actually been fixed? Is it in 4.21?

I am seeing something quite similar in both 4.21 and 4.23:
https://udn.unrealengine.com/questions/527191/a-crash-in-convertqueryimpacthit.html