# DataTable crashes only on standalone mode

**URL:** <https://forums.unrealengine.com/t/datatable-crashes-only-on-standalone-mode/465748>\
**Category:** Community & Industry Discussion\
**Tags:** datatable, unreal-engine, crash, standalone, CPP, question\
**Created:** [May 24, 2020, 7:05pm UTC](https://forums.unrealengine.com/t/datatable-crashes-only-on-standalone-mode/465748 "2020-05-24T19:05:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kastamones](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kastamones](https://forums.unrealengine.com/u/kastamones)\
**Post date:** [May 24, 2020, 7:05pm UTC](https://forums.unrealengine.com/t/datatable-crashes-only-on-standalone-mode/465748/1 "2020-05-24T19:05:17Z")

</div>

Hi everyone,

I am using my own datatables on the game and that works perfectly on PIE mode. Whenever I start standalone game, it cause crashes.

Error is:

```
Error LogWindows Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0xfffff21c
Error LogWindows           
Error LogWindows [Callstack] 0x00007ff9a48347d5 UE4Editor-CoreUObject.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ff9d84b9578 UE4Editor-RTS2-0007.dll!UDataTable::FindRow<FPredefinedGameMode>() [e:\ue\ue_4.24\engine\source\runtime\engine\classes\engine\datatable.h:203]

```

Code beIow is the way I use to read DataTable,

```
void DataStore::ReadGameInfoData()
{
	FSoftObjectPath UnitDataTablePath = FSoftObjectPath(TEXT("DataTable'/Game/Data/DefaultGameModes.DefaultGameModes'"));
	DefaultGameModesData = Cast<UDataTable>(UnitDataTablePath.ResolveObject());
	
	if (DefaultGameModesData == nullptr)
	{
		DefaultGameModesData = Cast<UDataTable>(UnitDataTablePath.TryLoad());
	} 
}

```

ReadGameInfoData function is called from GameInstance::Init function. And following DataStore::GetDefaultGameMode() function is called from GameMode::StartPlay function.

```
FRTSGameMode* DataStore::GetDefaultGameMode()
{
	LOG_ERR("GetDefaultGameMode ");
	if (DefaultGameModesData == nullptr)
	{
		LOG_ERR("DefaultGameModesData pointer is null");
		ReadGameInfoData();
	}
	
	FPredefinedGameMode* GM = DefaultGameModesData->FindRow<FPredefinedGameMode>("GameInfos", TEXT(""));

	if(GM != nullptr)
	{
		return GetRTSGameModeFromGameInfo(GM->ActiveGameModeIndex);
	}
	ensureMsgf(GM != nullptr, TEXT("GetDefaultGameMode GameModes is null"));
	return nullptr;	
}

```

Between “DefaultGameModesData pointer is null” log is never printed.

Thanks

---

<div class="post-metadata">

**Author:** ![kastamones](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kastamones](https://forums.unrealengine.com/u/kastamones)\
**Post date:** [May 25, 2020, 9:20pm UTC](https://forums.unrealengine.com/t/datatable-crashes-only-on-standalone-mode/465748/2 "2020-05-25T21:20:06Z")

</div>

A sentence **“Objects such as the GameInstance are created and initialized before starting the engine”** took my attention at following page [UE4 Game Flow](https://docs.unrealengine.com/en-US/Gameplay/Framework/GameFlow/index.html)

Somehow **TryLoad** function fails to load datatable, still it assigns the DefaultGameModesData pointer with a value other than nullptr, This could be an engine bug. Just because DefaultGameModesData is not nullptr anymore, I can not reload it.

The solution is below

I was calling **DataStore::ReadGameInfoData** function (function I load my datatable) from **GameInstance::Init** function, but Engine is not started at this stage according to documentattion. Then I move calling **DataStore::ReadGameInfoData** inside **GameMode::StartPlay** function. Then It worked.

---

<div class="post-metadata">

**Author:** ![SaintRQ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SaintRQ](https://forums.unrealengine.com/u/SaintRQ)\
**Post date:** [November 9, 2021, 2:52pm UTC](https://forums.unrealengine.com/t/datatable-crashes-only-on-standalone-mode/465748/3 "2021-11-09T14:52:31Z")

</div>

Thank you!!
