Crash -- FObjectFinders can't be used outside of constructors - hot reload only

I am getting this error after the editor crashes in the log files. This only happens on a hot-reload after code is compiled in VS.

I am using FObjectFinders in a constructor, but in a USTRUCT()

It is possible to restart the Editor without issue without this crash or error, and everything is loaded fine and it does display the Texture/Thumbnail in the Editor details on the object that is placed in the viewport…

Error from logs:

[2015.06.24-10.34.35:778][126]LogCrashTracker: 


[2015.06.24-10.34.35:779][126]LogWindows: === Critical error: ===
Fatal error: [File:G:\Unreal Source\UnrealEngine\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp] [Line: 2639] 
FObjectFinders can't be used outside of constructors to find Texture2D'/Game/Textures/Thumbnails/Home-icon.Home-icon'


KERNELBASE.dll {0x00007fff4ec11938} + 0 bytes
UE4Editor-Core.dll!FOutputDeviceWindowsError::Serialize() {0x00007fff1ec03b1f} + 0 bytes [g:\unreal source\unrealengine\engine\source\runtime\core\priv
UE4Editor-Core.dll!FOutputDevice::Logf__VA() {0x00007fff1eabf9a8} + 159 bytes [g:\unreal source\unrealengine\engine\source\runtime\core\priv
UE4Editor-Core.dll!FDebug::AssertFailed() {0x00007fff1ea90872} + 65 bytes [g:\unreal source\unrealengine\engine\source\runtime\core\priv
UE4Editor-CoreUObject.dll!ConstructorHelpers::CheckIfIsInConstructor() {0x00007fff28f5e097} + 0 bytes [g:\unreal source\unrealengine\engine\source\runtime\coreuobje
UE4Editor-CitySurvival-251.dll!ConstructorHelpers::FObjectFinder<UTexture2D>::FObjectFinder<UTexture2D>() {0x00007fff06a33ae8} + 0 bytes [g:\unreal source\unrealengine\engine\source\runtime\coreuobje
UE4Editor-CitySurvival-251.dll!FItemData::FItemData() {0x00007fff06a33fce} + 39 bytes [c:\users\\documents\unreal projects\citysurvival\source
UE4Editor-CitySurvival-251.dll!FItems::FItems() {0x00007fff06a341e6} + 244 bytes [c:\users\\documents\unreal projects\citysurvival\source
UE4Editor-CitySurvival-251.dll!ACitySurvivalGameMode::ACitySurvivalGameMode() {0x00007fff06a615c3} + 51 bytes [c:\users\\documents\unreal projects\citysurvival\interm
UE4Editor-CoreUObject.dll!UClass::HotReloadPrivateStaticClass() {0x00007fff28df04df} + 11 bytes [g:\unreal source\unrealengine\engine\source\runtime\coreuobje
UE4Editor-CitySurvival-251.dll!GetPrivateStaticClassBody<ACitySurvivalGameMode>() {0x00007fff06a5ce28} + 98 bytes [g:\unreal source\unrealengine\engine\source\runtime\coreuobje
UE4Editor-CitySurvival-251.dll!TClassCompiledInDefer<ACitySurvivalGameMode>::Register() {0x00007fff06a66ea1} + 45 bytes [g:\unreal source\unrealengine\engine\source\runtime\coreuobje
UE4Editor-CoreUObject.dll!UClassRegisterAllCompiledInClasses() {0x00007fff28f88b6a} + 0 bytes [g:\unreal source\unrealengine\engine\source\runtime\coreuobje
UE4Editor-CoreUObject.dll!ProcessNewlyLoadedUObjects() {0x00007fff28f76a27} + 5 bytes [g:\unreal source\unrealengine\engine\source\runtime\coreuobje
UE4Editor-CoreUObject.dll!TBaseStaticDelegateInstance<void __cdecl(void)>::ExecuteIfSafe() {0x00007fff28e78ae7} + 0 bytes [g:\unreal source\unrealengine\engine\source\runtime\core\publ
UE4Editor-Core.dll!TBaseMulticastDelegate<void>::Broadcast() {0x00007fff1e8b3abb} + 11 bytes [g:\unreal source\unrealengine\engine\source\runtime\core\publ
UE4Editor-Core.dll!FModuleManager::LoadModuleWithFailureReason() {0x00007fff1eabe853} + 0 bytes [g:\unreal source\unrealengine\engine\source\runtime\core\priv
UE4Editor-Core.dll!FModuleManager::LoadModule() {0x00007fff1eabdcb7} + 0 bytes [g:\unreal source\unrealengine\engine\source\runtime\core\priv
UE4Editor-HotReload.dll!FHotReloadModule::DoHotReloadInternal() {0x00007fff0aae88f8} + 44 bytes [g:\unreal source\unrealengine\engine\source\developer\hotrelo
UE4Editor-HotReload.dll!FHotReloadModule::DoHotReloadFromIDE() {0x00007fff0aae838a} + 194 bytes [g:\unreal source\unrealengine\engine\source\developer\hotrelo
UE4Editor-HotReload.dll!FHotReloadModule::Tick() {0x00007fff0aaf7640} + 0 bytes [g:\unreal source\unrealengine\engine\source\developer\hotrelo
UE4Editor-Core.dll!FTicker::Tick() {0x00007fff1e966618} + 32 bytes [g:\unreal source\unrealengine\engine\source\runtime\core\priv
UE4Editor.exe!FEngineLoop::Tick() {0x00007ff67c4d3962} + 0 bytes [g:\unreal source\unrealengine\engine\source\runtime\launch\pr
UE4Editor.exe!GuardedMain() {0x00007ff67c4c29dc} + 0 bytes [g:\unreal source\unrealengine\engine\source\runtime\launch\pr
UE4Editor.exe!GuardedMainWrapper() {0x00007ff67c4c2a5a} + 5 bytes [g:\unreal source\unrealengine\engine\source\runtime\launch\pr
UE4Editor.exe!WinMain() {0x00007ff67c4d45d9} + 17 bytes [g:\unreal source\unrealengine\engine\source\runtime\launch\pr
UE4Editor.exe!__tmainCRTStartup() {0x00007ff67c4d55c9} + 21 bytes [f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:618]
KERNEL32.DLL {0x00007fff50ee29a2} + 0 bytes
ntdll.dll {0x00007fff51ccb454} + 0 bytes
ntdll.dll {0x00007fff51ccb454} + 0 bytes

Effective Code:

FItemData(float space, FString DisName, FString IntName, TCHAR* Texture, EItemType Flags = EItemType::General, EItemQuality quality = EItemQuality::Average) : 
		Space(space), 
		DisplayName(DisName), 
		InternalName(IntName),
		Quality(quality),
		ItemType(Flags)
	{
		// Try to load the texture
		static ConstructorHelpers::FObjectFinder<UTexture2D> TexObj(Texture);

		if (TexObj.Object)
		{
			Image = TexObj.Object;
		}
	}
1 Like

Hi ,

I have a few questions for you as this seems related to a few other crash reports we’ve gotten lately.

  • Is this something that only happens in one particular project or are you able to recreate it in a fresh project, even if you move all of your code?
  • If it is only this one project, was this project converted from a previous version of the engine?
  • Are you using a binary version of the engine or was your engine compiled from source code?

I will try to answer your questions:

  1. I have not tried to reproduce this in a new project yet, I will do so if it will help the process…
  2. The code base of the project was converted from 4.7, but it was line by line (or copy paste by file) and verified to work before I added this code that is crashing.
  3. I am using an engine compiled from source.

Thanks

Can you provide me with the code that is related to this project? I see that you say that you’re using FObjectFinders in the constructor but in a UStruct, do you mean you’re creating a UStruct inside of you’re constructor and it is being used inside that declaration?

The Struct FItemData is used from within another data Struct that is created from (currently) the GameMode constructor. Looks like this:

Gamemode:

ACitySurvivalGameMode::ACitySurvivalGameMode()
{
	PlayerControllerClass = ACitySurvivalPlayerController::StaticClass();
	PlayerStateClass = ACitySurvivalPlayerState::StaticClass();
	DefaultPawnClass = AOverviewPawn::StaticClass();
	GameStateClass = ACitySurvivalGameState::StaticClass();

	GameItems = FItems();
}

FItems:

USTRUCT()
struct FItems
{
	GENERATED_BODY()

	// Weapons


	// Food
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = ItemFood)
	FItemData Apple;

	// Others

	FItems()
	{
		Apple = FItemData(1.0, TEXT("Apple"), TEXT("Apple"), TEXT("Texture2D'/Game/Textures/Thumbnails/Home-icon.Home-icon'"), (EItemType::Food | EItemType::General));
	}
};

Basicly the FObjectFinder is being used within the constructor of the USTRUCT. Didn’t want to play around with it to much to see if this is a valid bug, but FItems was planned to be static, or at least accessible from a static get.

I tried using your code and putting FObjectFinders in to see if it would crash to no avail. I still believe it may be something to do with conversion. Could you give a new project a try and migrate your assets / code over to see if it still persists?

Here is what I did…

  1. Regenerated the Project (just to be sure) Same Error
  2. Created a new project, moved all source over, did a clean build, Same Error
  3. Changed from the Locally built UE source (4.8.1) to the Binary managed by the UE4 launcher, Same error

So at this point I am at a lose… This problem is basicly just preventing me from HotReloading the editor. Currently I am building, running editor, making change, closing editor, building… etc…

Thank you for testing those various things. This tells us that the problem is in the code and that it isn’t just a conversion issue. It would be extremely helpful if you could send me your project, the new one would do if possible. If you’re uncomfortable with uploading it to the public, you can upload it to a third party site and send me a link through a private message on the forums. My username on the forums is . To reduce size, you can delete the Binaries, Content, Intermediate, and Saved folders when doing so.

If you cannot send me your project, please let me know and we’ll find out another way to proceed.

I have sent you the project file via private message on the forums. Thanks again

While this isn’t an answer to this problem directly (I would still like to know what has happened here to cause this crash)

I think I may have found a more elegant solution to my problem, which also seems to fix the issue with the crash, and probably (I am still unsure I could use clarification on this area) more efficient if I read the docs right:

FStringAssetReference to populate the TAssetPtr instead of searching for the reference with FObjectFinders and then it should load when it is needed instead of in each constructor, correct me if I am wrong.

So far, without any asset currently loaded into the game for play, it does seem to load in the editor correctly when viewing gamemode object in PIE play.

Hi ,

I was able to find the issue that is causing you to crash upon hot reloading and it is related to FObjectFinders.

In your ItemData.h file, you were using FObjectFinders to set something inside of a struct which will not work as it is meant to be used in a class’ constructor. Commenting out this code (and a few more lines to allow for it to compile) cause the crash to cease.

static ConstructorHelpers::FObjectFinder<UTexture2D> TexObj(Texture);

Hope this helps!

The only thing I find strange is that the code did run without issue from a cold start.

But it is understandable, and I was beginning to feel that was the issue, and had found TAssetPtr and FStringAssetReference, and FStreamManager along with some static singletons I have resolved this issue.

Thanks so much for taking the time on this.

Yes, I can confirm that. I had peppered ConstructorHelpers::FObjectFinder in customs class constructors that are class variables to a UObject thinking that they were, technically, in the UIObject’s constructor. Everything compiles, starts and executes well. When hot reload does its thing, that when I get the crash.

@ For me, the crash reporter only prints part of the message stated, though. I only have “FObjectFinders can’t” without any following message after that. I had to search the Engine source with these two words to understand what happened. Any chance of checking if there is a formatting problem when the error is now reported with 4.8.3 ?

Hi DrHobo,

Whenever you have a message that is cut off like that, you can always find the full version at the end of the crash log itself. To find the crash log, open the directory for the project that crashed and then go to Saved > Logs and select the latest .txt file. The reason this happens is because the crash reporter, in addition to adding in the full file path name, is trying to add the assert message but runs out of space. If, for some reason, you do need to find it in the source however, shortly before the assert text, it’ll show you the file and the Line #. In this case it was:

UObjectGlobals.cpp] [Line: 2639]

Have a nice day,