androidfirebaseandroid-ndkfirebase-dynamic-linksfirebase-invites

Firebase C++ SDK on Android Crashes with SIGSEGV fault addr 0x0 when creating dynamic link


We're using the Firebase C++ SDK for our iOS and Android game. On iOS creating dynamic links works just perfectly, but on Android we're getting crashes which we can't resolve even after countless hours of trying various things.

Here's the code that causes the crash:

  std::string appBundleId = getAppBundleIdentifier();

   firebase::dynamic_links::IOSParameters ios_parameters(appBundleId.c_str());

   firebase::dynamic_links::AndroidParameters android_parameters(appBundleId.c_str());

   firebase::dynamic_links::DynamicLinkComponents components(
           "https://example.com/", "abc123.app.goo.gl");
   components.android_parameters = &android_parameters;
   components.ios_parameters = &ios_parameters;

   // This log shows that the app is not nullptr
   MLLOG("Firebase Instance %s", firebase::App::GetInstance()->name());

   // The next line crashes
   firebase::dynamic_links::GeneratedDynamicLink longLink = firebase::dynamic_links::GetLongLink(components);

Here's the stacktrace, we obtained via adb logcat:

********** Crash dump: **********
Build fingerprint: 'samsung/kccat6xx/kccat6:6.0.1/MMB29M/G901FXXS1CPI4:user/release-keys'
pid: 22798, tid: 23065, name: GLThread 19076  >>> com.forestringgames.apps.towerduel <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Stack frame #00 pc 0416bed4  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN8firebase3App11GetInstanceEPKc+3)
Stack frame #01 pc 041620bf  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN8firebase13dynamic_links11GetLongLinkERKNS0_21DynamicLinkComponentsE+38)
Stack frame #02 pc 0306eb6f  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN15PlatformManager29createDynamicReferralLinkLongEv+226)
Stack frame #03 pc 0260a11f  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so
Stack frame #04 pc 0260b307  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so
Stack frame #05 pc 041c6df0  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNKSt8functionIFvPN7cocos2d3RefEEEclES2_+88)
Stack frame #06 pc 0430ce50  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d8MenuItem8activateEv+80)
Stack frame #07 pc 0430d908  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d13MenuItemLabel8activateEv+92)
Stack frame #08 pc 04308df4  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d4Menu12onTouchEndedEPNS_5TouchEPNS_5EventE+196)
Stack frame #09 pc 0430c3f8  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNKSt7_Mem_fnIMN7cocos2d4MenuEFvPNS0_5TouchEPNS0_5EventEEEclIJS3_S5_EvEEvPS1_DpOT_+172)
Stack frame #10 pc 0430c1fc  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNSt5_BindIFSt7_Mem_fnIMN7cocos2d4MenuEFvPNS1_5TouchEPNS1_5EventEEEPS2_St12_PlaceholderILi1EESB_ILi2EEEE6__callIvJOS4_OS6_EJLj0ELj1ELj2EEEET_OSt5tupleIJDpT0_EESt12_Index_tupleIJXspT1_EEE+200)
Stack frame #11 pc 0430be34  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNSt5_BindIFSt7_Mem_fnIMN7cocos2d4MenuEFvPNS1_5TouchEPNS1_5EventEEEPS2_St12_PlaceholderILi1EESB_ILi2EEEEclIJS4_S6_EvEET0_DpOT_+104)
Stack frame #12 pc 0430ba68  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNSt17_Function_handlerIFvPN7cocos2d5TouchEPNS0_5EventEESt5_BindIFSt7_Mem_fnIMNS0_4MenuEFvS2_S4_EEPS8_St12_PlaceholderILi1EESD_ILi2EEEEE9_M_invokeERKSt9_Any_dataS2_S4_+80)
Stack frame #13 pc 025e613d  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNKSt8functionIFvPN7cocos2d5TouchEPNS0_5EventEEEclES2_S4_+68)
Stack frame #14 pc 043de15c  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so
Stack frame #15 pc 043e5a08  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so
Stack frame #16 pc 043e1f64  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZNKSt8functionIFbPN7cocos2d13EventListenerEEEclES2_+88)
Stack frame #17 pc 043dd850  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d15EventDispatcher29dispatchTouchEventToListenersEPNS0_19EventListenerVectorERKSt8functionIFbPNS_13EventListenerEEE+1128)
Stack frame #18 pc 043de8c8  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d15EventDispatcher18dispatchTouchEventEPNS_10EventTouchE+552)
Stack frame #19 pc 043ddb90  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d15EventDispatcher13dispatchEventEPNS_5EventE+156)
Stack frame #20 pc 0438dc50  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d6GLView26handleTouchesOfEndOrCancelENS_10EventTouch9EventCodeEiPiPfS4_+732)
Stack frame #21 pc 0438dd88  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d6GLView16handleTouchesEndEiPiPfS2_+60)
Stack frame #22 pc 041469e1  /data/app/com.forestringgames.apps.towerduel-2/lib/arm/libcocos2dcpp.so (Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesEnd+68)
Stack frame #23 pc 01096e41  /data/app/com.forestringgames.apps.towerduel-2/oat/arm/base.odex (offset 0xaa1000) (void org.cocos2dx.lib.Cocos2dxRenderer.nativeTouchesEnd(int, float, float)+100)
Stack frame #24 pc 010971e3  /data/app/com.forestringgames.apps.towerduel-2/oat/arm/base.odex (offset 0xaa1000) (void org.cocos2dx.lib.Cocos2dxRenderer.handleActionUp(int, float, float)+70)
Stack frame #25 pc 010841a7  /data/app/com.forestringgames.apps.towerduel-2/oat/arm/base.odex (offset 0xaa1000) (void org.cocos2dx.lib.Cocos2dxGLSurfaceView$10.run()+170)
Stack frame #26 pc 03e4cd8d  /system/framework/arm/boot.oat (offset 0x2f48000)

Just in case this could be part of the problem, our firebase app seems to create successfully - we do it via a native call from onCreate:

JNIEXPORT void JNICALL Java_org_cocos2dx_cpp_AppActivity_onCreate(JNIEnv* env, jclass, jobject aMainActivity)
{
    MLLOG("java_org_cocos2dx_cpp_AppActivity_onCreate called");
     firebase::AppOptions appOptions;
    _firebaseApp = firebase::App::Create(appOptions, env, aMainActivity);
    auto app = firebase::App::GetInstance();

    // Both log the same pointer here
    MLLOG("FIREBASE APP INIT %p AppGetInstance %p", _firebaseApp, app);
}

Solution

  • have you tried initializing your app using

    ::firebase::dynamic_links::Initialize(app, null);
    

    before calling GetLongLink?