# Major - new weak\_map crashes game

**URL:** <https://forums.unrealengine.com/t/major-new-weak-map-crashes-game/1241585>\
**Category:** Issues and Bug Reporting\
**Tags:** unreal-engine, unreal-editor-for-fortnite, fortnite-creative, bug-report, fortnite\
**Created:** [July 27, 2023, 10:46am UTC](https://forums.unrealengine.com/t/major-new-weak-map-crashes-game/1241585 "2023-07-27T10:46:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![FinestCreative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/finestcreative/32/1034971_2.png) [@FinestCreative](https://forums.unrealengine.com/u/FinestCreative)\
**Post date:** [July 27, 2023, 10:46am UTC](https://forums.unrealengine.com/t/major-new-weak-map-crashes-game/1241585/1 "2023-07-27T10:46:43Z")

</div>

Calling this crashes the game 100% repro:

```auto
Func(Agent:agent):void={
    if(X := set GlobalInt[GetSession()] = if (Y := GlobalInt[GetSession()]) then Y + 1 else 0){Print("{X}")}
}

```

All details here:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/a/5/ba52963b80a3342fe8f6dc9ad0ed09e4be2b6683.jpeg "Bug weak map") ](https://www.youtube.com/watch?v=490edTggwmU)

---

<div class="post-metadata">

**Author:** ![jay.all.the.way](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jay.all.the.way](https://forums.unrealengine.com/u/jay.all.the.way)\
**Post date:** [July 27, 2023, 12:19pm UTC](https://forums.unrealengine.com/t/major-new-weak-map-crashes-game/1241585/2 "2023-07-27T12:19:32Z")

</div>

**Thank you for your report! We would like to look into this further, would you be able to submit a bug report using the form available here? [Fortnite Creative](https://creative.fortnite.com/s/bug-report)**

---

<div class="post-metadata">

**Author:** ![FinestCreative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/finestcreative/32/1034971_2.png) [@FinestCreative](https://forums.unrealengine.com/u/FinestCreative)\
**Post date:** [July 27, 2023, 3:04pm UTC](https://forums.unrealengine.com/t/major-new-weak-map-crashes-game/1241585/4 "2023-07-27T15:04:29Z")

</div>

its weird it works for normal map but not for weak\_map

---

<div class="post-metadata">

**Author:** ![Flak](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/flak/32/769441_2.png) [@Flak](https://forums.unrealengine.com/u/Flak)\
**Post date:** [July 28, 2023, 9:34pm UTC](https://forums.unrealengine.com/t/major-new-weak-map-crashes-game/1241585/5 "2023-07-28T21:34:42Z")

</div>

Hey Finest. 🙂

@FinestCreative - could you send me over the code you’re using with plain map that doesn’t fail?

---

<div class="post-metadata">

**Author:** ![FinestCreative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/finestcreative/32/1034971_2.png) [@FinestCreative](https://forums.unrealengine.com/u/FinestCreative)\
**Post date:** [July 29, 2023, 8:18am UTC](https://forums.unrealengine.com/t/major-new-weak-map-crashes-game/1241585/6 "2023-07-29T08:18:36Z")

</div>

```auto
Func(Agent:agent):void={
    if(X := set GlobalInt[GetSession()] = if (Y := GlobalInt[GetSession()]) then Y + 1 else 0){Print("{X}")}
}
FuncFromEpicPost(Agent:agent):void={
    X := if (Y := GlobalInt[GetSession()]) then Y + 1 else 0
    if:
        set GlobalInt[GetSession()] = X
    Print("{X}")
}
Func3(Agent:agent):void={
    var RegularMap:[int]int = map{}
    if(X := set RegularMap[0] = if (Y := RegularMap[0]) then Y + 1 else 0){Print("{X}")}
}

```

Func3 uses regular map

---

<div class="post-metadata">

**Author:** ![Flak](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/flak/32/769441_2.png) [@Flak](https://forums.unrealengine.com/u/Flak)\
**Post date:** [July 31, 2023, 11:21am UTC](https://forums.unrealengine.com/t/major-new-weak-map-crashes-game/1241585/7 "2023-07-31T11:21:20Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![spentak](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/spentak/32/642372_2.png) [@spentak](https://forums.unrealengine.com/u/spentak)\
**Post date:** [August 16, 2023, 4:53pm UTC](https://forums.unrealengine.com/t/major-new-weak-map-crashes-game/1241585/8 "2023-08-16T16:53:00Z")

</div>

Confirmed broken for round based games. GetSession and weak\_map work fine in game modes that don’t have rounds.

> [@weak\_map with GetSession Is broken and does not persist between rounds and crashes](https://forums.unrealengine.com/t/weak-map-with-getsession-is-broken-and-does-not-persist-between-rounds-and-crashes/1263028):
>
> GetSession() works with ANY type in a session so long as you don’t have a game with “rounds” With rounds, GetSession() + weak\_map will crash your game 99% of the time. In the code below you will see my test cases for GetSession in a round-based game. Can’t persist maps (critical for save data in multiplayer games) Persisting data at all crashes most of the time Again, in a non-round game, you can store any type of data in the weak\_map and GetSession works perfectly. using { /Fortnite.com/…

---

<div class="post-metadata">

**Author:** ![AxelCapek](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/axelcapek/32/950074_2.png) [@AxelCapek](https://forums.unrealengine.com/u/AxelCapek)\
**Post date:** [August 16, 2023, 5:34pm UTC](https://forums.unrealengine.com/t/major-new-weak-map-crashes-game/1241585/9 "2023-08-16T17:34:07Z")

</div>

Same here, also having session crashes when using weak map.
