# Cast to game instance makes editor crash at startup

**URL:** <https://forums.unrealengine.com/t/cast-to-game-instance-makes-editor-crash-at-startup/633822>\
**Category:** Blueprint\
**Tags:** casting, unreal-engine, UE5-0, Blueprint\
**Created:** [August 25, 2022, 2:29am UTC](https://forums.unrealengine.com/t/cast-to-game-instance-makes-editor-crash-at-startup/633822 "2022-08-25T02:29:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MoKeT79](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MoKeT79](https://forums.unrealengine.com/u/MoKeT79)\
**Post date:** [August 25, 2022, 2:29am UTC](https://forums.unrealengine.com/t/cast-to-game-instance-makes-editor-crash-at-startup/633822/1 "2022-08-25T02:29:23Z")

</div>

Hello,  
i am searching for help about my editor startup crash.

i found that the problem is comming from my cast to game instance.

i am doing a menu to get all the game items description in the main menu and when i add the cast to this menu it crashes, when i add it to the level blueprint to send it to the menu it crashes.  
cast to the instance works on my others widget in the game level.

i tried to create another empty level to load the instance before comming to the main menu and the cast makes the editor startup crash too.

the error crash is always acces violation with a different error code each time like 0x000000…

---

<div class="post-metadata">

**Author:** ![ZenLeviathan](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zenleviathan/32/551307_2.png) [@ZenLeviathan](https://forums.unrealengine.com/u/ZenLeviathan)\
**Post date:** [August 25, 2022, 6:40pm UTC](https://forums.unrealengine.com/t/cast-to-game-instance-makes-editor-crash-at-startup/633822/2 "2022-08-25T18:40:57Z")

</div>

Hey @MoKeT79, welcome to the forums!  
I think you may have a memory leak. You most likely just have a nullptr that trying to be accessed. Here’s a link to a solved forum post about it, you may find the steps you need to fix it in there: [[SOLVED] Access violation - code c0000005 (first/second chance not available) - #2 by ExtraLifeMatt](https://forums.unrealengine.com/t/solved-access-violation-code-c0000005-first-second-chance-not-available/122905/2)

I hope this can help!  
-Zen

---

<div class="post-metadata">

**Author:** ![MoKeT79](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MoKeT79](https://forums.unrealengine.com/u/MoKeT79)\
**Post date:** [August 25, 2022, 7:29pm UTC](https://forums.unrealengine.com/t/cast-to-game-instance-makes-editor-crash-at-startup/633822/3 "2022-08-25T19:29:38Z")

</div>

i tried to find where is the memory leak but i can’t figure how it happens, i just try to add the cast to my custom game instance with nothing else and it crash at startup.

here is the log if you can find something helpfull

[BananaInTime.log](https://forums.unrealengine.com/uploads/short-url/c563KPW8suXnHj0l1WpQRNGxz0Z.log) (157.2 KB)

---

<div class="post-metadata">

**Author:** ![BDC\_Patrick](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bdc_patrick/32/1104221_2.png) [@BDC\_Patrick](https://forums.unrealengine.com/u/BDC_Patrick)\
**Post date:** [August 26, 2022, 7:09am UTC](https://forums.unrealengine.com/t/cast-to-game-instance-makes-editor-crash-at-startup/633822/4 "2022-08-26T07:09:32Z")

</div>

any chance to see your Code?

Perhaps there is a timing problem, where you try to cast to something not fully initialized…

---

<div class="post-metadata">

**Author:** ![MoKeT79](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MoKeT79](https://forums.unrealengine.com/u/MoKeT79)\
**Post date:** [August 26, 2022, 1:18pm UTC](https://forums.unrealengine.com/t/cast-to-game-instance-makes-editor-crash-at-startup/633822/5 "2022-08-26T13:18:40Z")

</div>

i tried to add a delay too and crash again. i also created a new widget just to cast the instance and write some values at the same place in the blueprint and it worked well.

i really don’t understand what is happening 😕
