Description

Ranged-Based for in ULevelStreaming::BroadcastLevelVisibleStatus iterates an array which can become modified during execution if new levels are added.

------------------------------------------------------

ULevelStreaming::BroadcastLevelVisibleStatus iterates the UWorld::StreamingLevels
in a range-based-for, to broadcast OnLevelShown delegates for some levels.

If the implementation of the ULevelStreaming::OnLevelShown delegate invalidates the UWorld::StreamingLevels array, then you'll hit the ensure regarding array changing during ranged-for iteration.

ensureMsgf(Lhs.CurrentNum == Lhs.InitialNum, TEXT("Array has changed during ranged-for iteration!"));

An example would be trying to LoadLevelInstance for level B from within the OnLevelShown delegate for level A. This results in level B being added to UWorld::StreamingLevels.

Steps to Reproduce

.

Callstack

Error: Ensure condition failed: Lhs.CurrentNum == Lhs.InitialNum [Link Removed] [Line: 206]
Error: Array has changed during ranged-for iteration!
Error: Stack:
Error: [Callstack] 0x00007ffe30f871f6 UE4Editor-Core.dll!FWindowsPlatformStackWalk::StackWalkAndDump() [d:\build\++ue4\sync\engine\source\runtime\core\private\windows\windowsplatformstackwalk.cpp:236]
Error: [Callstack] 0x00007ffe30cc0c92 UE4Editor-Core.dll!FDebug::EnsureFailed() [d:\build\++ue4\sync\engine\source\runtime\core\private\misc\assertionmacros.cpp:305]
Error: [Callstack] 0x00007ffe30cdb356 UE4Editor-Core.dll!FDebug::OptionallyLogFormattedEnsureMessageReturningFalseImpl() [d:\build\++ue4\sync\engine\source\runtime\core\private\misc\assertionmacros.cpp:439]
Error: [Callstack] 0x00007ffe27b4ee8e UE4Editor-Engine.dll!ULevelStreaming::BroadcastLevelVisibleStatus() [d:\build\++ue4\sync\engine\source\runtime\engine\private\levelstreaming.cpp:1292]
Error: [Callstack] 0x00007ffe285573d0 UE4Editor-Engine.dll!UWorld::AddToWorld() [d:\build\++ue4\sync\engine\source\runtime\engine\private\world.cpp:2280]
Error: [Callstack] 0x00007ffe27b98a2a UE4Editor-Engine.dll!ULevelStreaming::UpdateStreamingState() [d:\build\++ue4\sync\engine\source\runtime\engine\private\levelstreaming.cpp:567]
Error: [Callstack] 0x00007ffe2859338b UE4Editor-Engine.dll!UWorld::UpdateLevelStreaming() [d:\build\++ue4\sync\engine\source\runtime\engine\private\world.cpp:2864]

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-64959 in the post.

0
Login to Vote

Fixed
ComponentUE - Gameplay
Affects Versions4.194.20
Target Fix4.21
Fix Commit4442519
Main Commit4450599
Release Commit4442519
CreatedOct 8, 2018
ResolvedOct 9, 2018
UpdatedSep 14, 2021