Crash in UWorld::SendAllEndOfFrameUpdates() for USceneComponents that have been deleted

I’ve run into what seems to be an engine bug that won’t happen in most use cases, but for my specific case it’s 100% reproducible. Basically World.h has a TSet called ComponentsThatNeedEndOfFrameUpdate_OnGameThread, which stores weak pointers to actor components. Any actor component can add itself to that set by calling UActorComponent::MarkForNeededEndOfFrameUpdate(). However, the issue I see is that most components never actually remove themselves from that list when they are unregistered, except for UPrimitiveComponent, which does so by calling World->ClearActorComponentEndOfFrameUpdate(this) inside its OnUnregister function. The reason this doesn’t cause issues most of the time is that UWorld::SendAllEndOfFrameUpdates() also clears the entire ComponentsThatNeedEndOfFrameUpdate_OnGameThread set after it is called. The weak pointers to the actor components will generally still be valid at that point because they haven’t been garbage collected yet. However, I have a case where I’m simulating the game state very far into the future, ticking the world many times before rendering the frame. So in my case, the weak pointers are pointing to dead objects by the time UWorld::SendAllEndOfFrameUpdates() is called. I believe this can be solved by calling World->ClearActorComponentEndOfFrameUpdate(this) for all ActorComponents, not just for PrimitiveComponents, but maybe there’s a better solution or something I’m missing. Thanks! Here is my stack trace as well:

Assertion failed: Component->GetMarkedForEndOfFrameUpdateState() == EComponentMarkedForEndOfFrameUpdateState::MarkedForGameThread [File:\unreal\Engine\Source\Runtime\Engine\Private\LevelTick.cpp] [Line: 917]

UE4Editor_Core!FDebug::AssertFailed() [\unreal\engine\source\runtime\core\private\misc\assertionmacros.cpp:332]
UE4Editor_Engine!::operator()() [\unreal\engine\source\runtime\engine\private\leveltick.cpp:918]
UE4Editor_Engine!ParallelForWithPreWork() [\unreal\engine\source\runtime\core\public\async\parallelfor.h:214]
UE4Editor_Engine!UWorld::SendAllEndOfFrameUpdates() [\unreal\engine\source\runtime\engine\private\leveltick.cpp:929]
UE4Editor_Renderer!FRendererModule::BeginRenderingViewFamily() [\unreal\engine\source\runtime\renderer\private\scenerendering.cpp:1755]
UE4Editor_Engine!UGameViewportClient::Draw() [\unreal\engine\source\runtime\engine\private\gameviewportclient.cpp:1129]
UE4Editor_Engine!FViewport::Draw() [\unreal\engine\source\runtime\engine\private\unrealclient.cpp:1163]
UE4Editor_UnrealEd!UEditorEngine::Tick() [\unreal\engine\source\editor\unrealed\private\editorengine.cpp:1618]
UE4Editor_UnrealEd!UUnrealEdEngine::Tick() [\unreal\engine\source\editor\unrealed\private\unrealedengine.cpp:371]
UE4Editor!FEngineLoop::Tick() [\unreal\engine\source\runtime\launch\private\launchengineloop.cpp:2859]
UE4Editor!GuardedMain() [\unreal\engine\source\runtime\launch\private\launch.cpp:152]
UE4Editor!GuardedMainWrapper() [\unreal\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() [\unreal\engine\source\runtime\launch\private\windows\launchwindows.cpp:202]
UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:264]
kernel32
ntdll