Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during unregister (done during emit) #27

Open
ContrerasA opened this issue Nov 10, 2022 · 2 comments
Open

Error during unregister (done during emit) #27

ContrerasA opened this issue Nov 10, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@ContrerasA
Copy link

I'm attempting to manually unregister a UPrimaryDataAsset listerner from an event

Registering via

	LambdaFunctionName = FGESHandler::DefaultHandler()->AddLambdaListener(Context, [this](UObject* ItemsAddedPayload) {
		OnItemAddedToInventoryEvent(ItemsAddedPayload);
	});

Unregistering via

FGESHandler::DefaultHandler()->RemoveLambdaListener(Context, LambdaFunctionName);

Upon calling RemoveLambdaListener, I am receiving the error below on the first instance/occurence.
If I simply play the game again, everything will work as it's supposed to.
However restarting the editor will once again cause this error to appear the first time RemoveLambdaListener is triggered.

LogOutputDevice: Error: === Handled ensure: ===
LogOutputDevice: Error: Ensure condition failed: Lhs.CurrentNum == Lhs.InitialNum [File:C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Containers\Array.h] [Line: 224]
LogOutputDevice: Error: Array has changed during ranged-for iteration!
LogOutputDevice: Error: Stack: 
LogOutputDevice: Error: [Callstack] 0x00007ffff98c0114 UnrealEditor-GlobalEventSystem.dll!FGESHandler::EmitToListenersWithData() [C:\Users\AnthonyC\Documents\Unreal Projects\GroceryStoreSim\Plugins\GlobalEventSystem-Unreal\Source\GlobalEventSystem\Private\GESHandler.cpp:482]
LogOutputDevice: Error: [Callstack] 0x00007ffff98bee3d UnrealEditor-GlobalEventSystem.dll!FGESHandler::EmitEvent() [C:\Users\AnthonyC\Documents\Unreal Projects\GroceryStoreSim\Plugins\GlobalEventSystem-Unreal\Source\GlobalEventSystem\Private\GESHandler.cpp:714]
LogOutputDevice: Error: [Callstack] 0x00007ffff92acdfd UnrealEditor-GroceryStoreSim.dll!UInventoryComponent::TryAddItem() [C:\Users\AnthonyC\Documents\Unreal Projects\GroceryStoreSim\Source\GroceryStoreSim\Private\Components\InventoryComponent.cpp:22]
LogOutputDevice: Error: [Callstack] 0x00007ffff92a96d2 UnrealEditor-GroceryStoreSim.dll!APickup::OnPickup() [C:\Users\AnthonyC\Documents\Unreal Projects\GroceryStoreSim\Source\GroceryStoreSim\Private\World\Pickup.cpp:36]
LogOutputDevice: Error: [Callstack] 0x00007ffff92b33e8 UnrealEditor-GroceryStoreSim.dll!APickup::execOnPickup() [C:\Users\AnthonyC\Documents\Unreal Projects\GroceryStoreSim\Intermediate\Build\Win64\UnrealEditor\Inc\GroceryStoreSim\Pickup.gen.cpp:30]
LogOutputDevice: Error: [Callstack] 0x00007fffb019bc07 UnrealEditor-CoreUObject.dll!UFunction::Invoke() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:5912]
LogOutputDevice: Error: [Callstack] 0x00007fffb03c1837 UnrealEditor-CoreUObject.dll!UObject::ProcessEvent() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:2003]
LogOutputDevice: Error: [Callstack] 0x00007fff820603f4 UnrealEditor-Engine.dll!AActor::ProcessEvent() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\Actor.cpp:1030]
LogOutputDevice: Error: [Callstack] 0x00007ffff92a6a8b UnrealEditor-GroceryStoreSim.dll!TMulticastScriptDelegate<FWeakObjectPtr>::ProcessMulticastDelegate<UObject>() [C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\UObject\ScriptDelegates.h:488]
LogOutputDevice: Error: [Callstack] 0x00007ffff92a73eb UnrealEditor-GroceryStoreSim.dll!UInteractableComponent::BeginInteract_Implementation() [C:\Users\AnthonyC\Documents\Unreal Projects\GroceryStoreSim\Source\GroceryStoreSim\Private\Components\InteractableComponent.cpp:46]
LogOutputDevice: Error: [Callstack] 0x00007ffff92b16a8 UnrealEditor-GroceryStoreSim.dll!UInteractableComponent::execBeginInteract() [C:\Users\AnthonyC\Documents\Unreal Projects\GroceryStoreSim\Intermediate\Build\Win64\UnrealEditor\Inc\GroceryStoreSim\InteractableComponent.gen.cpp:107]
LogOutputDevice: Error: [Callstack] 0x00007fffb019bc07 UnrealEditor-CoreUObject.dll!UFunction::Invoke() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:5912]
LogOutputDevice: Error: [Callstack] 0x00007fffb03c1837 UnrealEditor-CoreUObject.dll!UObject::ProcessEvent() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:2003]
LogOutputDevice: Error: [Callstack] 0x00007ffff92b141c UnrealEditor-GroceryStoreSim.dll!UInteractableComponent::BeginInteract() [C:\Users\AnthonyC\Documents\Unreal Projects\GroceryStoreSim\Intermediate\Build\Win64\UnrealEditor\Inc\GroceryStoreSim\InteractableComponent.gen.cpp:137]
LogOutputDevice: Error: [Callstack] 0x00007ffff92a8b9c UnrealEditor-GroceryStoreSim.dll!UInteractComponent::TryInteract() [C:\Users\AnthonyC\Documents\Unreal Projects\GroceryStoreSim\Source\GroceryStoreSim\Private\Components\InteractComponent.cpp:46]
LogOutputDevice: Error: [Callstack] 0x00007ffff92a86d5 UnrealEditor-GroceryStoreSim.dll!TBaseUObjectMethodDelegateInstance<0,UInteractComponent,void __cdecl(void),FDefaultDelegateUserPolicy>::Execute() [C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:594]
LogOutputDevice: Error: [Callstack] 0x00007fff83c8be2f UnrealEditor-Engine.dll!FInputActionUnifiedDelegate::Execute() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Classes\Components\InputComponent.h:288]
LogOutputDevice: Error: [Callstack] 0x00007fff83cbb743 UnrealEditor-Engine.dll!UPlayerInput::ProcessInputStack() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\UserInterface\PlayerInput.cpp:1419]
LogOutputDevice: Error: [Callstack] 0x00007fff83668268 UnrealEditor-Engine.dll!APlayerController::ProcessPlayerInput() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\PlayerController.cpp:2609]
LogOutputDevice: Error: [Callstack] 0x00007fff8367d4e5 UnrealEditor-Engine.dll!APlayerController::TickPlayerInput() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\PlayerController.cpp:4762]
LogOutputDevice: Error: [Callstack] 0x00007fff8366624d UnrealEditor-Engine.dll!APlayerController::PlayerTick() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\PlayerController.cpp:2234]
LogOutputDevice: Error: [Callstack] 0x00007fff8367c680 UnrealEditor-Engine.dll!APlayerController::TickActor() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\PlayerController.cpp:4914]
LogOutputDevice: Error: [Callstack] 0x00007fff8203ea96 UnrealEditor-Engine.dll!FActorTickFunction::ExecuteTick() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\Actor.cpp:197]
LogOutputDevice: Error: [Callstack] 0x00007fff83b55a0f UnrealEditor-Engine.dll!FTickFunctionTask::DoTask() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:284]
LogOutputDevice: Error: [Callstack] 0x00007fff83b5ccf8 UnrealEditor-Engine.dll!TGraphTask<FTickFunctionTask>::ExecuteTask() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:975]
LogOutputDevice: Error: [Callstack] 0x00007fff8c103a9d UnrealEditor-Core.dll!FNamedTaskThread::ProcessTasksNamedThread() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:753]
LogOutputDevice: Error: [Callstack] 0x00007fff8c103f3e UnrealEditor-Core.dll!FNamedTaskThread::ProcessTasksUntilQuit() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:642]
LogOutputDevice: Error: [Callstack] 0x00007fff8c10d6af UnrealEditor-Core.dll!FTaskGraphCompatibilityImplementation::WaitUntilTasksComplete() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:2169]
LogOutputDevice: Error: [Callstack] 0x00007fff83b72f0a UnrealEditor-Engine.dll!FTickTaskSequencer::ReleaseTickGroup() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:565]
LogOutputDevice: Error: [Callstack] 0x00007fff83b798b0 UnrealEditor-Engine.dll!FTickTaskManager::RunTickGroup() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:1592]
LogOutputDevice: Error: [Callstack] 0x00007fff82bbf08f UnrealEditor-Engine.dll!UWorld::RunTickGroup() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:790]
LogOutputDevice: Error: [Callstack] 0x00007fff82bc79c0 UnrealEditor-Engine.dll!UWorld::Tick() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:1531]
LogOutputDevice: Error: [Callstack] 0x00007fff8989e5f5 UnrealEditor-UnrealEd.dll!UEditorEngine::Tick() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\EditorEngine.cpp:1777]
LogOutputDevice: Error: [Callstack] 0x00007fff8a22aac6 UnrealEditor-UnrealEd.dll!UUnrealEdEngine::Tick() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\UnrealEdEngine.cpp:474]
LogOutputDevice: Error: [Callstack] 0x00007ff6e74582f6 UnrealEditor.exe!FEngineLoop::Tick() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:5215]
LogOutputDevice: Error: [Callstack] 0x00007ff6e7470d9c UnrealEditor.exe!GuardedMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:183]
LogOutputDevice: Error: [Callstack] 0x00007ff6e7470e8a UnrealEditor.exe!GuardedMainWrapper() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:147]
LogOutputDevice: Error: [Callstack] 0x00007ff6e7473c4d UnrealEditor.exe!LaunchWindowsStartup() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:283]
LogOutputDevice: Error: [Callstack] 0x00007ff6e7485564 UnrealEditor.exe!WinMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:330]
LogOutputDevice: Error: [Callstack] 0x00007ff6e7488736 UnrealEditor.exe!__scrt_common_main_seh() [d:\a01\_work\6\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
LogOutputDevice: Error: [Callstack] 0x00007ff83342244d KERNEL32.DLL!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ff83436df78 ntdll.dll!UnknownFunction []
@getnamo getnamo added the bug Something isn't working label Nov 11, 2022
@getnamo
Copy link
Owner

getnamo commented Nov 11, 2022

Based on the error it looks like you're removing the function during the same emit, might need try to unregister at a later call. That said this could be fixed with an array copy before iteration, though not sure if perf cost is worth it. Might be an approach I'm missing

@ContrerasA
Copy link
Author

Thanks for the heads up.
Yes, performing the deregistration at a later time has solved this issue. I'm simply calling the unregister function on the next frame instead

@getnamo getnamo changed the title Error during unregister Error during unregister (done during emit) Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants