You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Crash when connecting to a socket on iOS in distribution builds #442
I’m trying to build my project using Unreal Engine 5.4 for iOS. I use SocketIO 2.8.0 to connect to the backend. When trying to connect to the socket, a crash occurs. This only happens on iOS, only in Distribution builds, and only on Unreal 5.4. There are no problems on Unreal 5.2. Callstack: crashlog.txt
The callstack may be slightly different, but the problem is always when allocating or deallocating memory. I suspect that this may be a race condition and is related to some peculiarities of working with memory on iOS.
I tried using other versions of plugin, other versions of xcode, tried to build socket io using both c++20 and c++17, nothing helps.
iOS is not a primary platform I develop on, will likely have to depend on other devs to identify issue. Once a pull request with fix is opened I can merge it.
and the stack trace pointed into websocketpp / socket.io-client-cpp during HTTP header parsing.
Workaround That Fixed It
For me, the issue appears to be related to memory allocation differences in iOS Shipping/Distribution builds.
I resolved the crash by forcing Unreal Engine to use the ANSI allocator on iOS:
using UnrealBuildTool;
using System.Collections.Generic;
public class YourProjectTarget : TargetRules
{
public YourProjectTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
if (Target.Platform == UnrealTargetPlatform.IOS)
{
GlobalDefinitions.Add("FORCE_ANSI_ALLOCATOR=1");
}
}
}
### Steps
Add the above to your Game Target (.Target.cs)
Delete:
Binaries
Intermediate
Regenerate project files
Rebuild and archive again
Notes
This issue seems specific to iOS distribution/TestFlight builds
Development builds may work fine, which can make this tricky to debug
Likely related to how Unreal’s allocator interacts with socket.io-client-cpp / websocketpp on iOS
Activity
getnamo commentedon Dec 2, 2024
likely related issues: #431 (5.3) and #402
iOS is not a primary platform I develop on, will likely have to depend on other devs to identify issue. Once a pull request with fix is opened I can merge it.
omaralmasoud commentedon Mar 17, 2026
I was experiencing consistent crashes on iOS only in TestFlight / Distribution builds, while everything worked perfectly in Development builds.
The crash log showed:
___BUG_IN_CLIENT_OF_LIBMALLOC_POINTER_BEING_FREED_WAS_NOT_ALLOCATEDand the stack trace pointed into websocketpp / socket.io-client-cpp during HTTP header parsing.
Workaround That Fixed It
For me, the issue appears to be related to memory allocation differences in iOS Shipping/Distribution builds.
I resolved the crash by forcing Unreal Engine to use the ANSI allocator on iOS:
using UnrealBuildTool;
using System.Collections.Generic;
### Steps
Add the above to your Game Target (.Target.cs)
Delete:
Notes
getnamo commentedon Mar 18, 2026
Nice spot, if you make a pull request with the suggested code changes I'll merge it.
omaralmasoud commentedon Mar 19, 2026
Thanks! I've implemented the fix and opened a pull request with the changes.
This resolved the iOS TestFlight/distribution crash on my side. Let me know if you'd like any adjustments.