When packaging the project for Android, I used the UPL mechanism to remove unnecessary permissions, including network access permission:
<androidManifestUpdates>
<removePermission android:name="android.permission.INTERNET" />
<removePermission android:name="android.permission.ACCESS_NETWORK_STATE" />
<removePermission android:name="android.permission.ACCESS_WIFI_STATE" />
</androidManifestUpdates>
The application, which runs fine with that permission, now crashes.
It seems the problem is with FTcpListener, which experiences a segmentation error (please see log).
I did not use FTcpListener in my code, I don’t know why it is being executed.
Info: built for API level 19, OpenGL ES2, ATC. Problem observed both when launching from editor and when installing packaged .apk.
D/UE4 (15555): LogSockets:Warning: Failed to create socket Stream [FTcpListener server]
F/libc (15555): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 15645 (FTcpListener)
I/DEBUG (20265): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG (20265): Build fingerprint: 'samsung/hltexx/hlte:5.0/LRX21V/N9005XXUGBOK6:/release-keys'
I/DEBUG (20265): Revision: '8'
I/DEBUG (20265): ABI: 'arm'
I/DEBUG (20265): pid: 15555, tid: 15645, name: FTcpListener >>> net..unreality <<<
I/DEBUG (20265): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
I/DEBUG (20265): r0 00000000 r1 00000000 r2 913e1c48 r3 00003d1d
I/DEBUG (20265): r4 93fd28a0 r5 9575bfc0 r6 936fc010 r7 00000000
I/DEBUG (20265): r8 936fc060 r9 936fc0b0 sl 936fc100 fp 913e1d50
I/DEBUG (20265): ip a0f5a15c sp 913e1c40 lr b6f253f7 pc 9f1d2e10 cpsr 40070010
I/DEBUG (20265):
I/DEBUG (20265): backtrace:
I/DEBUG (20265): #00 pc 04d95e10 /data/app/net..unreality-1/lib/arm/libUE4.so (FTcpListener::Init()+760)
I/DEBUG (20265): #01 pc 01a4c94c /data/app/net..unreality-1/lib/arm/libUE4.so (FRunnableThreadPThread::Run()+120)
I/DEBUG (20265): #02 pc 019c68a0 /data/app/net..unreality-1/lib/arm/libUE4.so (FRunnableThreadPThread::_ThreadProc(void*)+184)
I/DEBUG (20265): #03 pc 000137bb /system/lib/libc.so (__pthread_start(void*)+30)
I/DEBUG (20265): #04 pc 0001189b /system/lib/libc.so (__start_thread+6)
Edit: I looked at the possible source of the crash.
The log message Failed to create socket
can be seen in [SocketSubsystemBSD.cpp][1] and is issued before returning a nullptr socket:
if (!NewSocket)
{
UE_LOG(LogSockets, Warning, TEXT("Failed to create socket %s [%s]"), *SocketType.ToString(), *SocketDescription);
}
return NewSocket;
The crash is happening in [FTcpListener::Init
][2]. As I understand it, the FTcpSockerBuilder returns nullptr and then the SetReceiveBufferSize
is called on nullptr.
Probably checking Socket != nullptr
again can fix that.
if (Socket == nullptr)
{
Socket = FTcpSocketBuilder(TEXT("FTcpListener server"))
.AsReusable()
.BoundToEndpoint(Endpoint)
.Listening(8);
// <- the log message suggests this returns nullptr
int32 NewSize = 0;
Socket->SetReceiveBufferSize(2*1024*1024, NewSize); // <- crash here?
}
I would be grateful for your help.
https://.com/EpicGames/UnrealEngine/blob/4.14/Engine/Source/Runtime/Sockets/Private/BSDSockets/SocketSubsystemBSD.cpp#L48
[2]: https://.com/EpicGames/UnrealEngine/blob/4.14/Engine/Source/Runtime/Networking/Public/Common/TcpListener.h#L137