# Crash when adding & removing many map keys?

**URL:** <https://forums.unrealengine.com/t/crash-when-adding-removing-many-map-keys/388278>\
**Category:** Blueprint\
**Tags:** tmap, unreal-engine, crash, bug-report, question, Blueprint\
**Created:** [March 18, 2017, 3:44am UTC](https://forums.unrealengine.com/t/crash-when-adding-removing-many-map-keys/388278 "2017-03-18T03:44:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ste1nar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ste1nar](https://forums.unrealengine.com/u/ste1nar)\
**Post date:** [March 18, 2017, 3:44am UTC](https://forums.unrealengine.com/t/crash-when-adding-removing-many-map-keys/388278/1 "2017-03-18T03:44:34Z")

</div>

**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**

> **[Dropbox - File Deleted](https://www.dropbox.com/sh/x3b9488vhjd68b9/AABEy8szzU1t_b9siFzmAtKya?dl=0)**
>
> Dropbox is a free service that lets you bring your photos, docs, and videos anywhere and share them easily. Never email yourself a file again!

**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.

---

<div class="post-metadata">

**Author:** ![ste1nar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ste1nar](https://forums.unrealengine.com/u/ste1nar)\
**Post date:** [March 18, 2017, 11:37am UTC](https://forums.unrealengine.com/t/crash-when-adding-removing-many-map-keys/388278/2 "2017-03-18T11:37:04Z")

</div>

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

 ![130685-mapcrashrepro.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/c/5/4c5b4dc375a81947d9b857a47a65e84d21773fc5.png)

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [March 22, 2017, 7:27pm UTC](https://forums.unrealengine.com/t/crash-when-adding-removing-many-map-keys/388278/3 "2017-03-22T19:27:50Z")

</div>

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)](https://issues.unrealengine.com/issue/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

---

<div class="post-metadata">

**Author:** ![ste1nar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ste1nar](https://forums.unrealengine.com/u/ste1nar)\
**Post date:** [March 23, 2017, 8:25pm UTC](https://forums.unrealengine.com/t/crash-when-adding-removing-many-map-keys/388278/4 "2017-03-23T20:25:22Z")

</div>

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.

 ![131432-keycrash.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/d/3/cd3e9bd60b6b6e603514c2c34e61f1bd316a7799.png)

Repro:

 ![131433-keycrashrepro2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/4/7/4478c26ba0d43345d3e879019e12ee1845f6d1e7.png)

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:

> **[Dropbox - File Deleted](https://www.dropbox.com/s/sqxs0wr5genaefo/BP%20copypaste.txt?dl=0)**
>
> Dropbox is a free service that lets you bring your photos, docs, and videos anywhere and share them easily. Never email yourself a file again!

---

<div class="post-metadata">

**Author:** ![42EspoiR](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@42EspoiR](https://forums.unrealengine.com/u/42EspoiR)\
**Post date:** [July 10, 2017, 12:53pm UTC](https://forums.unrealengine.com/t/crash-when-adding-removing-many-map-keys/388278/5 "2017-07-10T12:53:02Z")

</div>

Bug also affect TSet in Blueprint
