Hello
Long story short, been trying to create and run FSocket inside FRunnable as server on linux
There is the code of Run function that crashes:
virtual uint32 Run() override
{
while(bRunThread)
{
UE_LOG(LogTemp, Warning, TEXT("Runnable Thread Listening for incoming msgs from SubServers"));
TSharedRef<FInternetAddr> RemoteAddr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();
bool bPendingConnection;
if(this->Listener && this->Listener->HasPendingConnection(bPendingConnection) && bPendingConnection)
{
/*if(Connected)
{
Connected->Close();
ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->DestroySocket(Connected);
}
Connected = Listener->Accept(*RemoteAddr, TEXT("Receiver TCP Socket"));
if(Connected != NULL)
{
TArray<uint8> ReceivedData;
uint32 Size;
while(Connected->HasPendingData(Size))
{
ReceivedData.Empty(FMath::Min(Size, 65507u));
int32 Read = 0;
Connected->Recv(ReceivedData.GetData(), ReceivedData.Num(), Read);
//RECEIVED DATA
{
ReceivedData.Add(0);
FString s_receivedData = FString(ANSI_TO_TCHAR(reinterpret_cast<const char*>(ReceivedData.GetData())));
UE_LOG(LogTemp, Warning, TEXT("Received Data: %s"), *s_receivedData);
}
}
}*/
}
FPlatformProcess::Sleep(3.f);
}
return 0;
};
And I getting on Linux this message:
Signal 11 caught.
Malloc Size=65538 LargeMemoryPoolOffset=65554
CommonUnixCrashHandler: Signal=11
[2022.09.22-09.50.43:581][ 0]LogCore: === Critical error: ===
Unhandled Exception: SIGSEGV: unaligned memory access (SIMD vectors?)
[2022.09.22-09.50.43:581][ 0]LogCore: Fatal error!
0x00000000037da0c1 ServerTestsServer!FSubServerListner::Run() [D:/TestsUnreal/ServerTests/Source/ServerTests/MainServerGameMode.h:86]
0x00000000038d1207 ServerTestsServer!FRunnableThreadPThread::Run() [D:/UE_4.26_Source/Engine/Source/Runtime/Core/Private/HAL/PThreadRunnableThread.cpp:25]
0x000000000389c17c ServerTestsServer!FRunnableThreadPThread::_ThreadProc(void*) [D:/UE_4.26_Source/Engine/Source/Runtime/Core/Private/HAL/PThreadRunnableThread.h:185]
0x00007f08a029eea7 libpthread.so.0!UnknownFunction(0x7ea6)
0x00007f089fae1aef libc.so.6!clone(+0x3e)
[2022.09.22-09.50.43:592][ 0]LogExit: Executing StaticShutdownAfterError
Engine crash handling finished; re-raising signal 11 for the default handler. Good bye.
Segmentation fault (core dumped)
I been commenting blocks of this function till I find the crash, thoguh the error logs could help find the problem, it didn’t.
Looks like calling HasPendingConnection crashes it, because line 86 from crash error is exacly the if statment
if(this->Listener && this->Listener->HasPendingConnection(bPendingConnection) && bPendingConnection)
Any help that point me into solution is appreciated