Unknown exception - code 00000001 (first/second not available) when attempting to work with DataTables in C code

I’m attempting to work with C++ to implement a DataTable and then construct an instance of a “Character Profile” based on that data, with a reference returned via Blueprint method. I’ll then use that via Blueprints later for character stats and things.

Admittedly I’m a bit in over my head with trying to get this functionality to work and have managed to find myself in a situation where the editor crashes every time I hit the play button. The crash message is:

MachineId:D0656ED44FCAB401F28475A9DF62658C
EpicAccountId:

Unknown exception - code 00000001 (first/second  not available)

UE4Editor_Core!FDebug::AssertFailed() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\private\misc\outputdevice.cpp:355]
UE4Editor_UnrealEd!operator<<() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\editor\unrealed\private\editortransaction.cpp:157]
UE4Editor_UnrealEd!operator<<() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\public\containers\array.h:1212]
UE4Editor_UnrealEd!operator<<() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\public\containers\array.h:1212]
UE4Editor_UnrealEd!UTransBuffer::Serialize() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\editor\unrealed\private\editortransaction.cpp:405]
UE4Editor_UnrealEd!TFindObjectReferencers<UObject>::TFindObjectReferencers<UObject>() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\coreuobject\public\serialization\archiveuobject.h:513]
UE4Editor_UnrealEd!FReplaceReferenceHelper::FindAndReplaceReferences() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\editor\unrealed\private\kismet2\kismetreinstanceutilities.cpp:62]
UE4Editor_UnrealEd!FBlueprintCompileReinstancer::ReplaceInstancesOfClass() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\editor\unrealed\private\kismet2\kismetreinstanceutilities.cpp:1141]
UE4Editor_UnrealEd!FBlueprintCompileReinstancer::ReinstanceInner() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\editor\unrealed\private\kismet2\kismetreinstanceutilities.cpp:474]
UE4Editor_UnrealEd!FBlueprintCompileReinstancer::ReinstanceObjects() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\editor\unrealed\private\kismet2\kismetreinstanceutilities.cpp:561]
UE4Editor_UnrealEd!FKismetEditorUtilities::CompileBlueprint() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\editor\unrealed\private\kismet2\kismet2.cpp:780]
UE4Editor_Kismet!FBlueprintEditor::Compile() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\editor\kismet\private\blueprinteditor.cpp:3016]
UE4Editor_Kismet!FBlueprintEditor::ReparentBlueprint_NewParentChosen() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\editor\kismet\private\blueprinteditor.cpp:2563]
UE4Editor_Kismet!TBaseSPMethodDelegateInstance<0,FBlueprintEditor,0,TTypeWrapper<void> __cdecl(UClass * __ptr64)>::Execute() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\public\delegates\delegateinstancesimpl_variadics.inl:282]
UE4Editor_Kismet!TBaseSPMethodDelegateInstance<0,FBlueprintEditor,0,void __cdecl(UClass * __ptr64)>::ExecuteIfSafe() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\public\delegates\delegateinstancesimpl_variadics.inl:388]
UE4Editor_ClassViewer!SClassViewer::OnClassViewerSelectionChanged() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\editor\classviewer\private\sclassviewer.cpp:2205]
UE4Editor_ClassViewer!TBaseSPMethodDelegateInstance<0,SClassViewer,0,TTypeWrapper<void> __cdecl(TSharedPtr<FClassViewerNode,0>,enum ESelectInfo::Type)>::Execute() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\public\delegates\delegateinstancesimpl_variadics.inl:282]
UE4Editor_ClassViewer!TBaseSPMethodDelegateInstance<0,SClassViewer,0,void __cdecl(TSharedPtr<FClassViewerNode,0>,enum ESelectInfo::Type)>::ExecuteIfSafe() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\public\delegates\delegateinstancesimpl_variadics.inl:388]
UE4Editor_ClassViewer!TBaseDelegate<void,TSharedPtr<FClassViewerNode,0>,enum ESelectInfo::Type>::ExecuteIfBound() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\public\delegates\delegatesignatureimpl_variadics.inl:519]
UE4Editor_ClassViewer!SListView<TSharedPtr<FClassViewerNode,0> >::Private_SignalSelectionChanged() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\slate\public\widgets\views\slistview.h:609]
UE4Editor_ClassViewer!STableRow<TSharedPtr<FString,0> >::OnMouseButtonUp() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\slate\public\widgets\views\stablerow.h:437]
UE4Editor_Slate!<lambda_de96dc3471181973108233c6db1f9843>::operator()() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:4170]
UE4Editor_Slate!FEventRouter::Route<FReply,FEventRouter::FToLeafmostPolicy,FPointerEvent,<lambda_de96dc3471181973108233c6db1f9843> >() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:212]
UE4Editor_Slate!FSlateApplication::ProcessMouseButtonUpEvent() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:4173]
UE4Editor_Slate!FSlateApplication::OnMouseUp() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:4133]
UE4Editor_Core!FWindowsApplication::ProcessDeferredMessage() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\private\windows\windowsapplication.cpp:1403]
UE4Editor_Core!FWindowsApplication::DeferMessage() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\private\windows\windowsapplication.cpp:1708]
UE4Editor_Core!FWindowsApplication::ProcessMessage() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\private\windows\windowsapplication.cpp:706]
UE4Editor_Core!FWindowsApplication::AppWndProc() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\private\windows\windowsapplication.cpp:628]
user32
user32
UE4Editor_Core!FWindowsPlatformMisc::PumpMessages() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\private\windows\windowsplatformmisc.cpp:792]
UE4Editor!FEngineLoop::Tick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\launch\private\launchengineloop.cpp:2323]
UE4Editor!GuardedMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\launch\private\launch.cpp:142]
UE4Editor!GuardedMainWrapper() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\launch\private\windows\launchwindows.cpp:200]

By commenting out my C++ code I was able to make things go back to normal (not crash on clicking play) and uncommented piece by piece until it started crashing again. I’m left with the following:

UtilityClass.h

UCLASS()
class PROJECT_DREAMCATCHER_API UUtilityClass : public UObject
{
	GENERATED_BODY()
	
public:
	
	UFUNCTION( BlueprintCallable, Category = "Utility" )
		static UCharacterProfile* createDefaultCharacter();
};

UtilityClass.cpp

UCharacterProfile* UUtilityClass::createDefaultCharacter()
{
	UDataTable* CharacterProfileLookupTable;

	static ConstructorHelpers::FObjectFinder<UDataTable>CharacterProfileLookupTable_BP( TEXT( "DataTable'/Content/DreamcatcherAssets/Blueprints/Global/Project_Dreamcatcher_Character_Attributes.Project_Dreamcatcher_Character_Attributes'" ) );
	CharacterProfileLookupTable = CharacterProfileLookupTable_BP.Object;

	//static const FString ContextString( TEXT( "GENERAL" ) );
	//FGameCharacterLookupTable* lookupRow = CharacterProfileLookupTable->FindRow<FGameCharacterLookupTable>( *FString::Printf( TEXT( "%d" ),
	//	TEXT( "character1" ) ),
	//	ContextString);

	UCharacterProfile* newCharacter = NewObject<UCharacterProfile>( UCharacterProfile::StaticClass() );
	/*newCharacter->baseAttack = lookupRow->Base_Attack;
	newCharacter->baseDefense = lookupRow->Base_Defence;
	newCharacter->baseEnergy = lookupRow->Base_Energy;
	newCharacter->baseHealth = lookupRow->Base_Health;
	newCharacter->baseInitiative = lookupRow->Base_Initiative;
	newCharacter->baseMovementRange = lookupRow->Base_Movement;
	newCharacter->characterClass = lookupRow->Class;
	newCharacter->characterMesh = lookupRow->Character_Mesh;
	newCharacter->characterName = lookupRow->Name;*/
	return newCharacter;
}

I can provide the details of the Struct if you need me to.

A screenshot of the Blueprint which calls this function is attached.

The DataTable lives in: DataTable’/Game/DreamcatcherAssets/Blueprints/Global/Project_Dreamcatcher_Character_Attributes.Project_Dreamcatcher_Character_Attributes’ and only has 1 row at the moment.

This isn’t a whole lot to go on so let me know what else I can give you to help work this out.

Running DebugView at the same time gives me a little bit extra information:

[2428] Fatal error: [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.9\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp] [Line: 2710] 
[2428] FObjectFinders can't be used outside of constructors to find DataTable'/Content/DreamcatcherAssets/Blueprints/Global/Project_Dreamcatcher_Character_Attributes.Project_Dreamcatcher_Character_Attributes'

Possibility related to ConstructorHelper in function cause a crash - Programming & Scripting - Unreal Engine Forums

Seems you anwered your own question. ConstructorHelpers::FObjectFinder can only be used within the constructor. You could try using the following code and create a static member in your class called CharacterProfileLookupTable, which you can then reference later on.

static ConstructorHelpers::FObjectFinder<UDataTable>CharacterProfileLookupTable_BP( TEXT( "DataTable'/Content/DreamcatcherAssets/Blueprints/Global/Project_Dreamcatcher_Character_Attributes.Project_Dreamcatcher_Character_Attributes'" ) );
     CharacterProfileLookupTable = CharacterProfileLookupTable_BP.Object;

Hi Punitiate,

I just wanted to check and see if the solution mentioned by worked for you?