Download

Strange exception being thrown due to URadialForceComponent::FireImpulse(), could it be a bug?

So I have been following a course where they want you to make a grenade launcher weapon. I did that, but it had no physical impact and I wasn’t going to be satisfied until I could cause it to add radial force upon the projectile exploding. While searching for how to implement this properly, I discovered the RadialForceComponent.

I have a couple of simple box brush objects in my level, like this. Very quickly, I realized that if my RadialForceComponent->FireImpulse() function overlaps with the box brush during the explosion, it crashes the engine with an unhandled exception.

I spent some time stepping in the debugger to try and isolate this further.

First, FireImpulse() gets all overlapped Actors, and then does some operations on them. The first thing I noticed that seems wrong is this:

That first index is the box brush object. Notice how it says Actor is nullptr… whereas the second index is the normal Static Mesh floor component. I feel like the box brush object should not be showing nullptr.

Next, the code works its way down to this section at the very end of FireImpulse(), where it appears to be trying to get the owner of each overlapped object and see if it has a MovementComponent.

from RadialForceComponent.cpp, line 152:


// See if this is a target for a movement component, if so apply the impulse to it
        if (PrimitiveComponent->bIgnoreRadialImpulse == false)
        {
            TInlineComponentArray<UMovementComponent*> MovementComponents;
            PrimitiveComponent->GetOwner()->GetComponents<UMovementComponent>(MovementComponents);
            for (const auto& MovementComponent : MovementComponents)
            {
                if (MovementComponent->UpdatedComponent == PrimitiveComponent)
                {
                    MovementComponent->AddRadialImpulse(Origin, Radius, ImpulseStrength, Falloff, bImpulseVelChange);
                    break;
                }
            }
        }

Only the first 3 lines are important, because the crash happens each and every time when this function call is entered: PrimitiveComponent->GetOwner()->GetComponents<UMovementComponent>(MovementComponents);

From here, it gets super deep into engine code that I don’t really understand, but it’s doing a lot of Array/Allocator/Iterator operations, when it finally throws an exception with the message:

Exception thrown at 0x00007FFB729DEE1A (UE4Editor-Engine.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x0000000000000260.

This happens at a check call in a function that appears to be instantiating an allocator template, specifically on this line:

check(StartIndex >= 0 && StartIndex <= Array.Num());

So I guess I just felt like I was at a loss and didn’t know where else to turn, because I don’t understand why this geometry brush object is causing such an error to happen. I just hope that someone might have a clue as to how to address this.

Do I add exception handling to my game code? Do I assume this is unintended and is therefore a bug? Is this a known behavior because those geometry brush objects are meant for rough prototyping only, so I need to replace them all with real static meshes?

Any insight at all will be appreciated.