Crash when copying blueprint structures

This happens only in packaged builds. Game started from an editor works (and its logic also).

Output:

Assertion failed: Src [File:path\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp] [Line: 2288]
Game.exe has triggered a breakpoint.

Script Stack:

BuildingPrices_Functions_C.GetBuildingConfigByTierId
BP_GameMovementCharacter_C.ExecuteUbergraph_BP_GameMovementCharacter
BP_GameMovementCharacter_C.UpdateTooltip
W_BuilderUI_C.ExecuteUbergraph_W_BuilderUI
W_BuilderUI_C.BndEvt__StarterHouse_BTN_K2Node_ComponentBoundEvent_106_OnButtonHoverEvent__DelegateSignature

Source code Class.cpp

void UScriptStruct::CopyScriptStruct(void* InDest, void const* InSrc, int32 ArrayDim) const
{
	uint8 *Dest = (uint8*)InDest;
	check(Dest);
	uint8 const* Src = (uint8 const*)InSrc;
	check(Src);
	…
}

Let’s check last function in script stack: GetBuildingConfigByTierId. This is one of functions in our blueprint function library.

Buggy version:

Iterate through records from data table and find record that have proper TierId and Class, then save Config array (of type ResourceRequirementEntries) to temporary local variable.

Then:

Read from temporary variable and return array of ResourceRequirementEntries.

190361-2017-06-10_16h16_19.png

Structure: BuildingCostEntry:

Data table contains records of this type (above).

Structure: ResourceRequirementEntry:

Each record in data table has an array of entries (below).

190362-xxx.png

Engine crashed in CopyScriptStruct method, apparently it has issues with copying blueprint structures, so let’s try to avoid it.

Working version:

Iterate through records from data table and find record that have TierId and Class, then save corresponding row name in temporary variable.

Then:

Get record again by previously saved row name and return Config array.

This works.