[4.8.3] What is causing an "Access Violation" in "OverlapMultiByChannel()" of "physxcollision.cpp"?

This is the relevant part of my code:

FVector TempVector = (Start + FVector(Dir.Vector() * ( Range + Width) ));
FRotator TempRot = Dir;
TempRot.Pitch -= 90;

UWorld* const World = GetWorld();
TArray<struct FOverlapResult> TempOverlaps;
if (World)
{
	static FName NAME_LineOfSight = FName(TEXT("LineOfSight"));
	FCollisionQueryParams QueryParams(NAME_LineOfSight, true);
	QueryParams.AddIgnoredActor(Caster);
--->World->OverlapMultiByChannel(TempOverlaps, Start, FQuat(TempRot), ECollisionChannel::ECC_WorldDynamic, FCollisionShape::MakeCapsule(Width, Range), QueryParams);	
}

This is the Callstack after World->OverlapMultiByChannel() is called:

UE4Editor_Engine!FPxQueryFilterCallback::preFilter() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\engine\private\collision\physxcollision.cpp:618]
PhysX3PROFILE_x64
PhysX3PROFILE_x64
PhysX3PROFILE_x64
PhysX3PROFILE_x64
PhysX3PROFILE_x64
UE4Editor_Engine!GeomOverlapMultiImp_PhysX<0>() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\engine\private\collision\physxcollision.cpp:1610]
UE4Editor_Engine!GeomOverlapMultiImp<0>() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\engine\private\collision\physxcollision.cpp:1717]
UE4Editor_Engine!UWorld::OverlapMultiByChannel() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\engine\private\collision\worldcollision.cpp:199]

Error code:

Exception was "Access violation - code c0000005 (first/second chance not available)"

Source line in physxcollision.cpp the error is pointing to:

  617 ***** 	PxFilterData ShapeFilter = shape->getQueryFilterData();

I do not recall ever getting this error until yesterday.
The only change I made to my relevant code doesn’t occur until after World->OverlapMultiByChannel() is called.

The crash does not occur often, but in all cases(so far) one AI was firing projectiles at another AI that was returning fire with a beam(the beam uses OverlapMultiByChannel() function to determine potentially struck actors).

Any information on this crash and how it is related to the “shape”, would be helpful and much appreciated.

Having the same issue, and it seems like at tricky one :smiley:

For me, cleaning the project and recompile the codes, make the error disappear

Ok I’ve figured my issue out, but it doesn’t seem too connected to this one, at least that’s what I’ll presume without looking the crash log (that was eye opening to figure out I might add).
My issue with the code was I had several bodies (bombs sort of) emitting a radial blast and causing radial damage, as following:

  if (!bHasExploded)
	{
		TSubclassOf<UDamageType> DamageType;
		UGameplayStatics::ApplyRadialDamage(this, ExplosionStrength, GetActorLocation(), SphereRadius, DamageType, TArray<AActor *>(), this, nullptr, true, ECollisionChannel::ECC_Camera);
		RadialForceComponent->FireImpulse();
	}

The issue was that UGameplayStatics::ApplyRadialDamage calls the TakeDamage that calls UGameplayStatics::ApplyRadialDamage, meaning that they were each calling each other ad infinitum, untill I reached a memory limit and crashed the game. Solution:

if (!bHasExploded)
	{
		bHasExploded = true;    // marking as exploded BEFORE calling ApplyRadialDamage
		TSubclassOf<UDamageType> DamageType;
		UGameplayStatics::ApplyRadialDamage(this, ExplosionStrength, GetActorLocation(), SphereRadius, DamageType, TArray<AActor *>(), this, nullptr, true, ECollisionChannel::ECC_Camera);
		RadialForceComponent->FireImpulse();
	}

Hope this helps someone in the future.

It did help and you awesome for sharing! Thank you!