Hi, we’re seeing a fair number of crashes that seem to be related to a race condition initializing slate users. There’s an engine comment in FSlateApplication::RegisterNewUser that says “New users must be registered at a valid non-negative index that is not already occupied by another user” which makes sense. However, we’re getting a crash here due to the index being -1 after that check has already succeeded (when it attempts to call `Users[UserIndex] = NewUser`), implying that another thread is also modifying that memory.
We have not been able to consistently reproduce it internally, but a fair number of external users have managed to trigger the race condition.
Note that this callstack includes our modification to add support for gyro on steam controller [Content removed] but I do believe this issue is not inherent to that modification. It just provides a more frequent repro for the race condition so that’s the one we see most often in our crash reports. It looks theoretically possible for existing message handler function calls in the various vendor controller plugins to also trigger it if they’re called at just the wrong moment. (Also we attempted to add a scope lock at the top of FSlateApplication::RegisterNewUser with no success, therefore that line number in the callstack is one higher than it would be in vanilla 5.5.4.)
Game thread: [inlined] std::_Atomic_integral<T>::fetch_add (atomic:1507) [inlined] std::_Atomic_integral_facade<T>::fetch_sub (atomic:1723) [inlined] SharedPointerInternals::TReferenceControllerBase<T>::ReleaseSharedReference (SharedPointerInternals.h:222) SharedPointerInternals::FSharedReferencer<T>::operator= (SharedPointerInternals.h:653) [inlined] TSharedPtr<T>::operator= (SharedPointer.h:931) FSlateApplication::RegisterNewUser (SlateApplication.cpp:4398) [inlined] FSlateApplication::RegisterNewUser (SlateApplication.cpp:4364) FSlateApplication::GetOrCreateUser (SlateApplication.cpp:4344) [inlined] FSlateApplication::GetOrCreateUser (SlateApplication.h:1160) FSlateApplication::ProcessMotionDetectedEvent (SlateApplication.cpp:6622) FSlateApplication::OnMotionDetected (SlateApplication.cpp:6604) FSteamController::SendControllerEvents (SteamController.cpp:242) FWindowsApplication::PollGameDeviceState (WindowsApplication.cpp:2860) FEngineLoop::Tick (LaunchEngineLoop.cpp:5861) [inlined] EngineTick (Launch.cpp:69) GuardedMain (Launch.cpp:190) GuardedMainWrapper (LaunchWindows.cpp:123) LaunchWindowsStartup (LaunchWindows.cpp:287) WinMain (LaunchWindows.cpp:327)
Would you have any recommendations for guarding against this situation?