Subclass of UHierarchicalInstancedStaticMeshComponent causes crash on Hot-Reload

Engine version: 4.15.2

Steps to reproduce:

  1. Create Basic code c++ project

  2. Add c++ subclass of UHierarchicalInstancedStaticMeshComponent

  3. Add property to your GameModeBase class (or any other class, but not to hierarchical instanced mesh subclass we created in step 2 ), this is just to trigger hot reload:

    public:
    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    int32 TestProperty;

4 Compile project in editor

5 Crash:

Assertion failed: IsValid() [File:D:\Build\++UE4+Release-4.15+Compile\Sync\Engine\Source\Runtime\Core\Public\Templates/SharedPointer.h] [Line: 826] 

UE4Editor_Core!FDebug::AssertFailed() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\core\private\misc\assertionmacros.cpp:349]
UE4Editor_Engine!UHierarchicalInstancedStaticMeshComponent::Serialize() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\engine\private\hierarchicalinstancedstaticmesh.cpp:1796]
UE4Editor_CoreUObject!FFindReferencersArchive::ResetPotentialReferencer() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\coreuobject\private\serialization\findreferencersarchive.cpp:90]
UE4Editor_UnrealEd!TFindObjectReferencers<UObject>::TFindObjectReferencers<UObject>() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\coreuobject\public\serialization\findobjectreferencers.h:49]
UE4Editor_UnrealEd!FReplaceReferenceHelper::FindAndReplaceReferences() [d:\build\++ue4+release-4.15+compile\sync\engine\source\editor\unrealed\private\kismet2\kismetreinstanceutilities.cpp:81]
UE4Editor_UnrealEd!FBlueprintCompileReinstancer::ReplaceInstancesOfClass_Inner() [d:\build\++ue4+release-4.15+compile\sync\engine\source\editor\unrealed\private\kismet2\kismetreinstanceutilities.cpp:1937]
UE4Editor_UnrealEd!FBlueprintCompileReinstancer::ReplaceInstancesOfClass() [d:\build\++ue4+release-4.15+compile\sync\engine\source\editor\unrealed\private\kismet2\kismetreinstanceutilities.cpp:1476]
UE4Editor_UnrealEd!FBlueprintCompileReinstancer::ReinstanceInner() [d:\build\++ue4+release-4.15+compile\sync\engine\source\editor\unrealed\private\kismet2\kismetreinstanceutilities.cpp:682]
UE4Editor_UnrealEd!FBlueprintCompileReinstancer::ReinstanceObjects() [d:\build\++ue4+release-4.15+compile\sync\engine\source\editor\unrealed\private\kismet2\kismetreinstanceutilities.cpp:913]
UE4Editor_HotReload!FHotReloadModule::ReinstanceClass() [d:\build\++ue4+release-4.15+compile\sync\engine\source\developer\hotreload\private\hotreload.cpp:1271]
UE4Editor_HotReload!FHotReloadModule::ReinstanceClasses() [d:\build\++ue4+release-4.15+compile\sync\engine\source\developer\hotreload\private\hotreload.cpp:1254]
UE4Editor_HotReload!TBaseRawMethodDelegateInstance<0,FHotReloadModule,void __cdecl(void)>::ExecuteIfSafe() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\core\public\delegates\delegateinstancesimpl.h:648]
UE4Editor_CoreUObject!TBaseMulticastDelegate<void>::Broadcast() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\core\public\delegates\delegatesignatureimpl.inl:937]
UE4Editor_CoreUObject!UClassReplaceHotReloadClasses() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:720]
UE4Editor_CoreUObject!ProcessNewlyLoadedUObjects() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:858]
UE4Editor_CoreUObject!TBaseStaticDelegateInstance<void __cdecl(void)>::ExecuteIfSafe() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\core\public\delegates\delegateinstancesimpl.h:1027]
UE4Editor_Core!TBaseMulticastDelegate<void>::Broadcast() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\core\public\delegates\delegatesignatureimpl.inl:937]
UE4Editor_Core!FModuleManager::LoadModuleWithFailureReason() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\core\private\modules\modulemanager.cpp:471]
UE4Editor_Core!FModuleManager::LoadModule() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\core\private\modules\modulemanager.cpp:330]
UE4Editor_HotReload!FHotReloadModule::DoHotReloadInternal() [d:\build\++ue4+release-4.15+compile\sync\engine\source\developer\hotreload\private\hotreload.cpp:856]
UE4Editor_HotReload!UE4Function_Private::TFunctionRefCaller<<lambda_845f9b2944b03bbc30be1e1f4a8d7f4b>,void __cdecl(TMap<FString,FString,FDefaultSetAllocator,TDefaultMapKeyFuncs<FString,FString,0> > const & __ptr64,bool,enum ECompilationResult::Type)>::Call() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\core\public\templates\function.h:245]
UE4Editor_HotReload!FHotReloadModule::CheckForFinishedModuleDLLCompile() [d:\build\++ue4+release-4.15+compile\sync\engine\source\developer\hotreload\private\hotreload.cpp:1916]
UE4Editor_HotReload!FHotReloadModule::Tick() [d:\build\++ue4+release-4.15+compile\sync\engine\source\developer\hotreload\private\hotreload.cpp:594]
UE4Editor_UnrealEd!UEditorEngine::Tick() [d:\build\++ue4+release-4.15+compile\sync\engine\source\editor\unrealed\private\editorengine.cpp:1236]
UE4Editor_UnrealEd!UUnrealEdEngine::Tick() [d:\build\++ue4+release-4.15+compile\sync\engine\source\editor\unrealed\private\unrealedengine.cpp:391]
UE4Editor!FEngineLoop::Tick() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\launch\private\launchengineloop.cpp:3025]
UE4Editor!GuardedMain() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\launch\private\launch.cpp:166]
UE4Editor!GuardedMainWrapper() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:134]
UE4Editor!WinMain() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:210]
UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:264]
kernel32

Hey -

Thank you for submitting a bug report. I have reproduced this issue and logged a report for it here Unreal Engine Issues and Bug Tracker (UE-45028) . You can track the report’s status as the issue is reviewed by our development staff. Please be aware that this issue may not be prioritized or fixed soon.

Cheers

Alright, thank you for your response. Probably worth mentioning that because of this bug you can’t use hot reload if you have custom c++ Foliage Component (as UFoliageInstancedStaticMeshComponent is subclass of HISM Component)

Hi , my project has started running into this issue as well and it’s hampering productivity quite a bit as I essentially can’t hot-reload anymore.

Hoping that community interest on this can be bumped up. I see that UE-35710 has been backlogged while UE-45028 is still open; hopeful that one of those will be taken up.

Some additional info: I’ve used custom HISMs for a very long time now but never had this issue until recently. If I mange to figure out what triggered this issue I’ll post back with a comment.

Hey -

I have updated UE-45028 to indicate this is still affecting the community and that it still occurs in 4.17 as well.

I found a workaround which I quickly wanted to share!

I migrated my HISM subclass to a separate gameplay module and now refer that module from by primary game module’s Build.cs. With this setup I can hotreload again, which is a big relief.

If you’re new to setting up gameplay modules check out this doc and/or use any of Epic’s modules or a simple plugin module as reference.

Hope this tidbit helps someone in the same situation :slight_smile:

Issue still occurs in 4.19 … Dear Unreal, plz fix.

I tried 's fix, and it still seems to crash :unamused:

4.19.2 this bug happens to me too. It crashes when I compile from editor, then if I restart the editor and compile again it works fine…unfortunately this is a routine that I have to do every single time I want to compile from editor (crash, restart and compile)

I ran into this in UE 4.20.

It looks like the bug is that, when scanning for references after hot reloading, it’s dereferencing “ClusterTreePtr” - which is null for the class default object.

My workaround for now is to override “Serialize()” like so:

void UMyDerivedHISMComponent::Serialize(FArchive& Ar)
{
	bool hasTempClusterTreePtr = false;
	if (Ar.IsObjectReferenceCollector() && !ClusterTreePtr.IsValid())
	{
		ClusterTreePtr = MakeShareable(new TArray<FClusterNode>);
		hasTempClusterTreePtr = true;
	}

	Super::Serialize(Ar);

	if (hasTempClusterTreePtr)
	{
		ClusterTreePtr = nullptr;
	}
}

Even in 4.24.1, the bug still exists.