SIGSEGV on startup on Android client built with UE 4.21

Hi,
starting from this repo I’m trying to run GameLiftClient on Android. Following this this guide too I managed to compile and package the project, but the app crashes with a segmentation fault when Aws::InitAPI() is called.

This is the log from logcat:

A/libc(12286): Fatal signal 11 (SIGSEGV), code 2, fault addr 0xdddddddd in tid 12300 (Thread-3360)
A/DEBUG(2034): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
A/DEBUG(2034): Build fingerprint: 'lge/p1_global_com/p1:6.0/MRA58K/160160109a98e:user/release-keys'
A/DEBUG(2034): Revision: '11'
A/DEBUG(2034): ABI: 'arm'
A/DEBUG(2034): pid: 12286, tid: 12300, name: Thread-3360 >>> com.YourCompany.MyProject <<<
A/DEBUG(2034): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0xdddddddd
A/DEBUG(2034): r0 cf7a4ae0 r1 dddddddd r2 f7100625 r3 f711f000
A/DEBUG(2034): r4 cbad9ac4 r5 cf7a4aac r6 f391e909 r7 cc1f716c
A/DEBUG(2034): r8 cf7a4ae0 r9 cf7a4ab0 sl ca7bc550 fp cf7a5118
A/DEBUG(2034): ip f382119c sp cf7a4a50 lr f37bae5d pc f38ec246 cpsr 60070030
A/DEBUG(2034): backtrace:
A/DEBUG(2034): #00 pc 000a7246 /data/app/com.YourCompany.MyProject-1/lib/arm/libaws-cpp-sdk-core.so (Aws::InitAPI(Aws::SDKOptions const&)+629)
A/DEBUG(2034): #01 pc 02c4b390 /data/app/com.YourCompany.MyProject-1/lib/arm/libUE4.so (FAWSCoreModule::StartupModule()+224)
A/DEBUG(2034): #02 pc 0337beec /data/app/com.YourCompany.MyProject-1/lib/arm/libUE4.so (FModuleManager::LoadModuleWithFailureReason(FName, EModuleLoadResult&)+2284)
A/DEBUG(2034): #03 pc 0357c924 /data/app/com.YourCompany.MyProject-1/lib/arm/libUE4.so (FModuleDescriptor::LoadModulesForPhase(ELoadingPhase::Type, TArray<FModuleDescriptor, FDefaultAllocator> const&, TMap<FName, EModuleLoadResult, FDefaultSetAllocator, TDefaultMapHashableKeyFuncs<FName, EModuleLoadResult, false> >&)+704)
A/DEBUG(2034): #04 pc 035967dc /data/app/com.YourCompany.MyProject-1/lib/arm/libUE4.so
A/DEBUG(2034): #05 pc 03595e9c /data/app/com.YourCompany.MyProject-1/lib/arm/libUE4.so (FPluginManager::LoadModulesForEnabledPlugins(ELoadingPhase::Type)+936)
A/DEBUG(2034): #06 pc 0294c280 /data/app/com.YourCompany.MyProject-1/lib/arm/libUE4.so (FEngineLoop::LoadStartupModules()+392)
A/DEBUG(2034): #07 pc 0294401c /data/app/com.YourCompany.MyProject-1/lib/arm/libUE4.so (FEngineLoop::PreInit(char16_t const*)+21508)
A/DEBUG(2034): #08 pc 0292a0e0 /data/app/com.YourCompany.MyProject-1/lib/arm/libUE4.so (FEngineLoop::PreInit(int, char16_t**, char16_t const*)+3892)
A/DEBUG(2034): #09 pc 029286dc /data/app/com.YourCompany.MyProject-1/lib/arm/libUE4.so (AndroidMain(android_app*)+3440)
A/DEBUG(2034): #10 pc 0293b304 /data/app/com.YourCompany.MyProject-1/lib/arm/libUE4.so (android_main+208)
A/DEBUG(2034): #11 pc 02964558 /data/app/com.YourCompany.MyProject-1/lib/arm/libUE4.so
A/DEBUG(2034): #12 pc 0003f9a3 /system/lib/libc.so (__pthread_start(void*)+30)
A/DEBUG(2034): #13 pc 0001a0c5 /system/lib/libc.so (__start_thread+6)

InitAPI() is called from the class AWSCoreModule that implements IModuleInterface, so Aws::InitAPI() is called inside the StartupModule() function. options is declared in the header file.

    void FAWSCoreModule::StartupModule()
{
Aws::InitAPI(options);
LOG_NORMAL("Aws::InitAPI called.");
}
void FAWSCoreModule::ShutdownModule()
{
Aws::ShutdownAPI(options);
LOG_NORMAL("Aws::ShutdownAPI called.");
}<br>

The library file libaws-cpp-sdk-core.so is loaded from AWSCore.Build.cs using PublicAdditionalLibraries.Add().
Also, I made an xml file, as suggested in the second link, that copies libaws-cpp-sdk-core.so into the apk’s lib folder, then loads aws-cpp-sdk-core from inside .

The xml file is also loaded via AdditionalPropertiesForReceipt.Add(), as the wiki does.

I feel like I’m doing this the right way, but missing something. Can somebody help me figure this out?

Thank you in advance for your help.

EDIT:

After building the aws sdk with CMAKE_BUILD_TYPE=Debug, a new line appeared in the segmentation fault in logcat.

A/DEBUG(2034): #00 pc 00138f04 /data/app/com.YourCompany.MyProject-1/lib/arm/libaws-cpp-sdk-core.so (std::__ndk1::function<std::__ndk1::shared_ptr<Aws::Utils::Crypto::SymmetricCipherFactory> ()>::operator()() const+24)
A/DEBUG(2034): #01 pc 00138944 /data/app/com.YourCompany.MyProject-1/lib/arm/libaws-cpp-sdk-core.so (Aws::InitAPI(Aws::SDKOptions const&)+1456)

Also, for sake of clarity, the following are the parameters I pass to cmake:

-DBUILD_FOR_UNREAL=1
-G “NMake Makefiles”
-DBUILD_ONLY=“core;gamelift;cognito-identity;events”
-DTARGET_ARCH=ANDROID
-DNDK_DIR=C:\Users\ximera\AppData\Local\Android\Sdk\android-ndk-r12b -DCMAKE_BUILD_TYPE=Debug
-DENABLE_UNITY_BUILD=ON
-DFORCE_SHARED_CRT=OFF
-DSIMPLE_INSTALL=OFF

Hello @ximera,

Sorry for the delay in our response. I am the specialist that has been assigned to help you.

Typically it is bad form to call GameLift directly from the client, since no authentication is performed. You should make a call to your backend to do this for you.

The general flow that you are trying to create is this:

  1. The client makes a call to your own back-end to request matchmaking. This could be an API Gateway with a Lambda, or some other infrastructure that manages the online features of your title. (If you want to dive deeper in designing this, then we can help you here). What you don’t do is call GameLiftStartMatchmaking from the client.
  2. The backend authenticates the player, so you know who they are and that they are real, and the backend initiates matchmaking using the GameLift client SDK (available as part of the AWS SDK in the language of your choice), which eventually contacts a server.
  3. The server called InitSDK() when it started, and also ProcessReady() in the GameLift Server SDK. This put it in a mode to accept game sessions.
  4. The matching completes and your server is told that a game session is placed on it. This calls the onGameSessionStart() callback on the server
  5. The server loads the map, starts listening for players on the game port that you have selected, and calls ActivateGameSession() in the GameLift Server SDK.
  6. GameLift completes the matchmaking ticket, and as soon as you are notified, your backend receives the IP address and port of the server, also a session token.
  7. You pass the connection info back to the clients from the backend.
  8. The clients make connections to the server on the IP address and port that they received.
  9. The server validates the session token, which you must pass when you connect. The clients are now connected to the server and gameplay begins.
    The guide that you are using is something that Unreal support would be more able to help you with, so I will refer you to them as to why the library crashes on startup. If you get stuck there feel free to send me an email at ly-community@amazon.com requesting to be routed to me, and I can engage with you further by email.

Thank you,

Al Murray :)
Solutions Architect, Amazon Game Tech

@ximera

Hello, @Ximera, how were you able to package for android using the gamelift client? I’m having some issues here. Any help will be appreciated.