[4.7 Bug] Crash when looping through EmitterInstances in UParticleSystemComponent

Hello,

I get crash when I am looping though EmitterInstances in 4.7 like this:

for (int i = 0; i < EmitterInstances.Num(); i++)
{
}

So if use EmitterInstances[i] without null check it it will crash now.
Everything was ok in 4.6.

Hi ,

Sorry for the delay in responding to this post. I just tried to reproduce this in version 4.7.1 that released today, and did not see the results that you described. Would you be able to provide some additional information?

  • Do you still see this happening in either of the released versions of 4.7 (4.7.0 or 4.7.1)?
  • Does this only happen in your project, or do you see the same results in a new project?
  • Could you provide the full code of your custom ParticleSystemComponent?

Hey,
Yes i got the same crash without null check when looping through particle with beam emitters in latest 4.7

void USpellParticleComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
    if (SpellParticleInfo)
    {
         for (int i = 0; i < EmitterInstances.Num(); i++)
         {
              // crash when no null check
              if (EmitterInstances[i] && EmitterInstances[i]->bIsBeam)
                  SetBeamTargetPoint(i,  TargetInfo.Target->GetSocketPoint(SocketType, TargetInfo.Caster), 0);
         }
    }

   Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
}

Like I said i did not have this in 4.6

I made another attempt to reproduce this using the code you provided in a custom ParticleComponent class, and I was still unable to make the Engine crash. Here is what I have been doing to set this up.

  • Create new code project using first person template, no starter content.

  • Create new code class derived from ParticleSystemComponent.

  • Close the Editor.

  • Add the following code to the source file for the new particle system component class:

    void UMyParticleSystemComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
    {
    for (int i = 0; i < EmitterInstances.Num(); i++)
    {
    if (EmitterInstances[i] && EmitterInstances[i]->bIsBeam)
    {
    SetBeamTargetPoint(i, FVector(1, 0, 0), 0);
    }
    }

     Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
    

    }

  • Build the project in Visual Studio.

  • Open the project in the Editor.

  • Create an Actor Blueprint.

  • Add one of the custom ParticleSystemComponents to the new Blueprint.

  • Place an instance of the new Blueprint into the level.

  • Play the game in PIE mode.

What are you doing differently in your case? Could you provide the callstack for the crash?

I get the crash when there is no EmitterInstances[i] null check. Maybe it something wrong with blueprint after it was converted from 4.6 to 4.7. I will try to recreate this.

I tried both with and without the EmitterInstances[i] check, as well as the EmitterInstances[i]->bIsBeam check. I also just tried again with a project created in 4.6.1 then upgraded to 4.7.2. If you get a to recreate this, would you be able to zip up the project and send it to us?

Hi ,

We have not heard back from you for some time. Do you still help with this issue? I will be marking this issue as resolved for tracking purposes, but please feel free to re-open this post if you still need any additional help.