Access Violation from FText Comparison


				/*if (!oldName) //this doesn't work, nor did (oldName == nullptr)
				{
					UE_LOG(LogTemp, Error, TEXT("WHYYYYYYYYY"));
					oldName = Characters[i].Name;
				}*/

				Characters[i] = FCharacterData(character, character->ID);
				if (character->Name.EqualTo(oldName)) //<---HERE
				{
					UE_LOG(LogTemp, Log, TEXT("Character %s modified"), *character->Name.ToString());
				}
				else
				{
					UE_LOG(LogTemp, Log, TEXT("Old character %s saved as %s"), *oldName.ToString(), *character->Name.ToString());
				}
EpicAccountId:8b27c0b42c364499b37567ce74566df7

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000000

UE4Editor_Core!FText::CompareTo() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Internationalization\ICUText.cpp:98]
UE4Editor_Core!FText::EqualTo() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Internationalization\ICUText.cpp:114]
UE4Editor_GenericTactics!UGTSaveGame::SaveCharacter() [D:\My Documents\Unreal\GenericTactics\Source\GenericTactics\Player\GTSaveGame.cpp:59]
UE4Editor_CoreUObject!UFunction::Invoke() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:5679]
UE4Editor_CoreUObject!UObject::CallFunction() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1023]
UE4Editor_CoreUObject!UObject::ProcessContextOpcode() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:2896]
UE4Editor_CoreUObject!ProcessLocalScriptFunction() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1093]
UE4Editor_CoreUObject!UObject::ProcessInternal() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1181]
UE4Editor_CoreUObject!UFunction::Invoke() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:5679]
UE4Editor_CoreUObject!UObject::ProcessEvent() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:2018]
UE4Editor_CoreUObject!TMulticastScriptDelegate<FWeakObjectPtr>::ProcessMulticastDelegate<UObject>() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Public\UObject\ScriptDelegates.h:488]
UE4Editor_CoreUObject!FCallDelegateHelper::CallMulticastDelegate() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:3072]
UE4Editor_CoreUObject!ProcessLocalScriptFunction() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1093]
UE4Editor_CoreUObject!ProcessScriptFunction<void (__cdecl*)(UObject *,FFrame &,void *)>() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:924]
UE4Editor_CoreUObject!ProcessLocalFunction() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1154]
UE4Editor_CoreUObject!ProcessLocalScriptFunction() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1093]
UE4Editor_CoreUObject!UObject::ProcessInternal() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1181]
UE4Editor_CoreUObject!UFunction::Invoke() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:5679]
UE4Editor_CoreUObject!UObject::ProcessEvent() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:2018]
UE4Editor_UMG!TMulticastScriptDelegate<FWeakObjectPtr>::ProcessMulticastDelegate<UObject>() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Public\UObject\ScriptDelegates.h:488]
UE4Editor_UMG!UButton::SlateHandleClicked() [D:\Build\++UE4\Sync\Engine\Source\Runtime\UMG\Private\Components\Button.cpp:205]
UE4Editor_UMG!TBaseUObjectMethodDelegateInstance<0,UButton,FReply __cdecl(void),FDefaultDelegateUserPolicy>::Execute() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:593]
UE4Editor_Slate!SButton::ExecuteOnClick() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Slate\Private\Widgets\Input\SButton.cpp:385]
UE4Editor_Slate!SButton::OnMouseButtonUp() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Slate\Private\Widgets\Input\SButton.cpp:304]
UE4Editor_Slate!FEventRouter::Route<FReply,FEventRouter::FToLeafmostPolicy,FPointerEvent,<lambda_cc5aea9e7377b04ce85c30c65ec3889b> >() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp:378]
UE4Editor_Slate!FSlateApplication::RoutePointerUpEvent() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp:4831]
UE4Editor_Slate!FSlateApplication::ProcessMouseButtonUpEvent() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp:5372]
UE4Editor_Slate!FSlateApplication::OnMouseUp() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp:5337]
UE4Editor_ApplicationCore!FWindowsApplication::ProcessDeferredMessage() [D:\Build\++UE4\Sync\Engine\Source\Runtime\ApplicationCore\Private\Windows\WindowsApplication.cpp:2205]
UE4Editor_ApplicationCore!FWindowsApplication::DeferMessage() [D:\Build\++UE4\Sync\Engine\Source\Runtime\ApplicationCore\Private\Windows\WindowsApplication.cpp:2698]
UE4Editor_ApplicationCore!FWindowsApplication::ProcessMessage() [D:\Build\++UE4\Sync\Engine\Source\Runtime\ApplicationCore\Private\Windows\WindowsApplication.cpp:1881]
UE4Editor_ApplicationCore!FWindowsApplication::AppWndProc() [D:\Build\++UE4\Sync\Engine\Source\Runtime\ApplicationCore\Private\Windows\WindowsApplication.cpp:905]
user32
user32
UE4Editor_ApplicationCore!FWindowsPlatformApplicationMisc::PumpMessages() [D:\Build\++UE4\Sync\Engine\Source\Runtime\ApplicationCore\Private\Windows\WindowsPlatformApplicationMisc.cpp:125]
UE4Editor!FEngineLoop::Tick() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:4850]
UE4Editor!GuardedMain() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:178]
UE4Editor!GuardedMainWrapper() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:137]
UE4Editor!LaunchWindowsStartup() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:273]
UE4Editor!WinMain() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:320]
UE4Editor!__scrt_common_main_seh() [d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
kernel32
ntdll

this keeps happening with no rhyme or reason. FText and Characters[i] can’t be null-checked; character is null-checked before this section of code.

Maybe you could do a IsEmpty() check on Characters[i]?

1 Like

‘IsEmpty’: is not a member of ‘FCharacterData’

What does Does constructor of FCharacterData return when passing in character and character->ID?

Can you check the return length to check if it is zero length?

isEmpty() is part of FText as an alternative to a null check

tried checking IsEmpty on oldName: get access violation

not sure what you mean by the length of FCharacterData, but it’s not the source of the problem. The crash is always in relation to oldName.