Crash when adding & removing many map keys?

Context

I am placing area damaging actors, which damages pawns as they trigger an overlap event. That is done not directly, but instead the overlap gets a status effects component of the pawn, telling it to add a new key value pair to a map. The key is the area actor (as UObject class). When the pawn leaves the volume, the area actor removes the effect.

Issue

While overlapping a few area actors simultaniously seems to be fine, overlapping several causes a crash, seemingly when exiting the volumes.

Debugging

The first step in debugging this, I have created a fresh FPS project and in the player character setup a way to directly spawn the area actors and adding them to the status effects map, as well as removing them. Note that the overlap volume are of type vehicle, and is set to ignore vehicle so that they should not be triggering each other.

A very important note here is that I am simply spawning them and adding & removing them to the map - I am not actually ever triggering their overlaps, leading me to think it is a map problem.

Project

Using Project & Information

FirstPersonCharacter contains the logic for spawning the area actors and passing them to the status effects component. The N variable determines how many to spawn each time.

StatusEffectsComponent contains methods for adding to and removing from the map. There’s an Enum “Use Type” to determine if UObject, Actor or Name should be used and can be switched between freely between simulations. I can’t tell if the different map type used has different crashing results or not.
It also has a tick which constantly applies damage to the pawn for each key, but that happens silently.

Gun can be fired to shoot a projectile which spawns area actors each collision.

Area actors are placed in groups in the map for testing overlap.

E - spawns area actors and tells the status effects component to add them.

R - iterates over all spawned area actors, tells the status effects component to remove them and then calls their destroy function. then clears the array.

T - prints information about the selected map.

causing a crash

  1. Press E. Press R. Repeat up to 5 times and the project should crash, it does for me.
  2. Press E, walk over some area actors. It should crash, but it may depend of which map type is being used.

Or, you know, alternatively you can create the following setup.

It won’t crash the first time you add & remove, but after a couple of presses, it crashes for me. Even if the loop count is set lower.

Hey -

Thank you for submitting a bug report. I have reproduced this issue and logged a report for it here Unreal Engine Issues and Bug Tracker (UE-43210) . You can track the report’s status as the issue is reviewed by our development staff. Please be aware that this issue may not be prioritized or fixed soon.

Cheers

Hello, I’d like to provide some more information. This is something I really hope gets fixed.

It seems that there is a chance the bug will happen, only when removing from a map and that map has to have at least 3 keys remaining after the removal.

In the following picture the top row crashed, while the bottom left one was not a crash. The number shows how many times a key was added and removed, and only when it received the required number of keys, it crashed.

Interestingly, it does not crash directly, but actually lets the whole function execute.

Repro:

Information:

  1. Press X and C to verify that it does not crash with less than 4 keys.
  2. Input the tick to verify that it can successfully add and remove keys, press X until 4 keys are added and it will crash momentarily.

Copy-paste of blueprint nodes with print strings:

Bug also affect TSet in Blueprint