Fatal Error trying to modify UObject map (find or add) that is currently being iterated

When I try to load the other levels and build the project I get the following critical error

UATHelper: Packaging (Windows): LogWindows: Error: begin: stack for UAT
UATHelper: Packaging (Windows): LogWindows: Error: === Critical error: ===
UATHelper: Packaging (Windows): LogWindows: Error:
UATHelper: Packaging (Windows): LogWindows: Error: Fatal error: [File:D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectHash.cpp] [Line: 319]
UATHelper: Packaging (Windows): LogWindows: Error: Trying to modify UObject map (FindOrAdd) that is currently being iterated. Please make sure you’re not creating new UObjects or Garbage Collecting while iterating UObject hash tables.
UATHelper: Packaging (Windows): LogWindows: Error:
UATHelper: Packaging (Windows): LogWindows: Error:
UATHelper: Packaging (Windows): LogWindows: Error:
UATHelper: Packaging (Windows): LogWindows: Error:
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffcb19030db UnrealEditor-CoreUObject.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffcb18e2d50 UnrealEditor-CoreUObject.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffcb1924978 UnrealEditor-CoreUObject.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffcb1925f7e UnrealEditor-CoreUObject.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffcb1927426 UnrealEditor-CoreUObject.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffcb1926ee6 UnrealEditor-CoreUObject.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca5d78a46 UnrealEditor-UnrealEd.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca39dfbe3 UnrealEditor-Kismet.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca3984167 UnrealEditor-Kismet.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca3983f20 UnrealEditor-Kismet.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca5cf018a UnrealEditor-UnrealEd.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca0acd4c2 UnrealEditor-BlueprintGraph.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca0b665a0 UnrealEditor-BlueprintGraph.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca0b72621 UnrealEditor-BlueprintGraph.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca0b51c96 UnrealEditor-BlueprintGraph.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca0addb7c UnrealEditor-BlueprintGraph.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca0b6e38c UnrealEditor-BlueprintGraph.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca0b6ea9d UnrealEditor-BlueprintGraph.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca732b767 UnrealEditor-Engine.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffcb18facf6 UnrealEditor-CoreUObject.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca90e3964 UnrealEditor-Engine.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca9109a14 UnrealEditor-Engine.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca90e1f1b UnrealEditor-Engine.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca5729a8b UnrealEditor-UnrealEd.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca56a3fea UnrealEditor-UnrealEd.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca570add7 UnrealEditor-UnrealEd.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca572f4e0 UnrealEditor-UnrealEd.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca553b1bd UnrealEditor-UnrealEd.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffca555cb5c UnrealEditor-UnrealEd.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff6c008948e UnrealEditor-Cmd.exe!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff6c0080bbd UnrealEditor-Cmd.exe!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff6c0080e8a UnrealEditor-Cmd.exe!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff6c0083c4d UnrealEditor-Cmd.exe!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff6c0095564 UnrealEditor-Cmd.exe!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff6c009788a UnrealEditor-Cmd.exe!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffd1f1e74b4 KERNEL32.DLL!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffd1f3226a1 ntdll.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error:
UATHelper: Packaging (Windows): LogWindows: Error: end: stack for UAT
PackagingResults: Error: begin: stack for UAT
PackagingResults: Error: === Critical error: ===
PackagingResults: Error: Fatal error: [File:D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectHash.cpp] [Line: 319]
PackagingResults: Error: Trying to modify UObject map (FindOrAdd) that is currently being iterated. Please make sure you’re not creating new UObjects or Garbage Collecting while iterating UObject hash tables.
PackagingResults: Error: [Callstack] 0x00007ffcb19030db UnrealEditor-CoreUObject.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffcb18e2d50 UnrealEditor-CoreUObject.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffcb1924978 UnrealEditor-CoreUObject.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffcb1925f7e UnrealEditor-CoreUObject.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffcb1927426 UnrealEditor-CoreUObject.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffcb1926ee6 UnrealEditor-CoreUObject.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca5d78a46 UnrealEditor-UnrealEd.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca39dfbe3 UnrealEditor-Kismet.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca3984167 UnrealEditor-Kismet.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca3983f20 UnrealEditor-Kismet.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca5cf018a UnrealEditor-UnrealEd.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca0acd4c2 UnrealEditor-BlueprintGraph.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca0b665a0 UnrealEditor-BlueprintGraph.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca0b72621 UnrealEditor-BlueprintGraph.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca0b51c96 UnrealEditor-BlueprintGraph.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca0addb7c UnrealEditor-BlueprintGraph.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca0b6e38c UnrealEditor-BlueprintGraph.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca0b6ea9d UnrealEditor-BlueprintGraph.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca732b767 UnrealEditor-Engine.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffcb18facf6 UnrealEditor-CoreUObject.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca90e3964 UnrealEditor-Engine.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca9109a14 UnrealEditor-Engine.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca90e1f1b UnrealEditor-Engine.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca5729a8b UnrealEditor-UnrealEd.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca56a3fea UnrealEditor-UnrealEd.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca570add7 UnrealEditor-UnrealEd.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca572f4e0 UnrealEditor-UnrealEd.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca553b1bd UnrealEditor-UnrealEd.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffca555cb5c UnrealEditor-UnrealEd.dll!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ff6c008948e UnrealEditor-Cmd.exe!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ff6c0080bbd UnrealEditor-Cmd.exe!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ff6c0080e8a UnrealEditor-Cmd.exe!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ff6c0083c4d UnrealEditor-Cmd.exe!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ff6c0095564 UnrealEditor-Cmd.exe!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ff6c009788a UnrealEditor-Cmd.exe!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffd1f1e74b4 KERNEL32.DLL!UnknownFunction []
PackagingResults: Error: [Callstack] 0x00007ffd1f3226a1 ntdll.dll!UnknownFunction []
PackagingResults: Error: end: stack for UAT

Is there anything I am missing? What should I do?

It seems your map collection is being garbage collected. Make sure you TMap has a UPROPERTY macro above it to ensure it is not garbage collected.

You also seem to be trying to change an entry in the tmap while iterating it. Instead of modifying it in the loop (bad idea), find the key you want to modify and change it outside of the loop.