Skip to content

.Create causes SIGABRT crash #27

@ruby0x1

Description

@ruby0x1

I've been trying out the SDK, but have ended up stuck with a hard to debug crash.
I would have filed this on the SDK repo but there isn't one, so this is the next best option since I'm using the code here as direct reference :)

The following line causes the crash, but only after it returns:
service = builder.Create(conf);

If I don't call create (but configure everything before it) it continues without issue.

Possibly relevant information:

  • I am running a Nexus 5x, Android 6.0.1 (latest updates)
  • Building on NDK r10e, SDK is up to date, compileSdkVersion 23
  • Building with gradle/android studio
    • using compile 'com.google.android.gms:play-services:8.4.0'
    • I don't have any apply lines related to the play services
  • I am using SDL 2.0.4 stable as the basis of the app
  • The app ID is set up and configured on the developer console
  • checkJNI is enabled
  • I use JNI_OnLoad initialization

The code below is a bit verbose because I have been trying to debug this a while.

static std::unique_ptr< ::gpg::GameServices> service;

void init() {

    if(service == nullptr) {

        LOGI("INIT JVM:%p", jvm);

        JNIEnv* env;

        int state = jvm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
        if (state == JNI_EDETACHED) {
            LOGI("INIT: GetEnv: not attached, attaching ... ");
            if (jvm->AttachCurrentThread(&env, NULL) != 0) {
                LOGI("INIT: GetEnv: FAILED TO ATTACH");
            } else {
                LOGI("INIT: GetEnv: ATTACHED OK");
            }
        } else if (state == JNI_OK) {
            LOGI("INIT: GetEnv: JNI_OK");
        } else if (state == JNI_EVERSION) {
            LOGI("INIT: GetEnv: JNI_EVERSION: version not supported");
        }

        LOGI("INIT ENV:%p", env);

        jclass localclass = env->FindClass("org/snowkit/snowbasic/AppActivity");                          LOGI("local class %p",localclass);
        jclass globalclass = reinterpret_cast<jclass>(env->NewGlobalRef(localclass));                     LOGI("global class %p",globalclass);

        jmethodID mid = env->GetStaticMethodID(globalclass, "getActivity","()Landroid/app/Activity;");    LOGI("mid %p",mid);
        jobject localactivity = env->CallStaticObjectMethod(globalclass, mid);                            LOGI("local activity %p",localactivity);
        jobject globalactivity = reinterpret_cast<jobject>(env->NewGlobalRef(localactivity));             LOGI("global activity %p",globalactivity);

        ::gpg::AndroidPlatformConfiguration conf;
        conf.SetActivity(globalactivity);

        ::gpg::GameServices::Builder builder;

            builder.SetDefaultOnLog(::gpg::LogLevel::VERBOSE);

            builder.SetOnAuthActionStarted([&](::gpg::AuthOperation op) {
                LOGI("OnAuthActionStarted");
            });

            builder.SetOnAuthActionFinished([&](::gpg::AuthOperation op, ::gpg::AuthStatus status) {
                LOGI("AuthActionFinished, status: %d", status);
            });

        service = builder.Create(conf);

        LOGI("INIT: DONE");

    } //service != null

} //init

I have explicitly added the getActivity function to check that it was sane.
The selfActivity instance is set inside of onCreate.

    public static Activity getActivity() {
        Log.i("APP",">>>>>>>>/ Get Activity / " + selfActivity);
        return selfActivity;
    }

And finally, here is the logcat output at the time of the crash.
In case it's not clear:
GPG = the native code above
app = C++ code of the app, from a touch event (happens no matter where I call from)
APP = java code of the app

I app     : touch released, GPG not inited, calling init()
I GPG     : INIT JVM:0xf4ebc000
I GPG     : INIT: GetEnv: JNI_OK
I GPG     : INIT ENV:0xeb311e40
I GPG     : local class 0x200005
I GPG     : global class 0x706
I GPG     : mid 0xf08730c8
I APP     : >>>>>>>>/ Get Activity / org.snowkit.snowbasic.AppActivity@640263b
I GPG     : local activity 0x200009
I GPG     : global activity 0x70a
V GamesNativeSDK: Using classes from /data/user/0/org.snowkit.snowbasic/app_.gpg.classloader/7756dc0d15d18341bd94e20177d1a3f8.jar.
W PopupManager: You have not specified a View to use as content view for popups. Falling back to the Activity content view. Note that this may not work as expected in multi-screen environments
I GPG     : INIT: DONE
I app     : touch released, done
F libc    : Fatal signal 6 (SIGABRT), code -6 in tid 29282 (SDLThread)
F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
F DEBUG   : Build fingerprint: 'google/bullhead/bullhead:6.0.1/MMB29K/2419427:user/release-keys'
F DEBUG   : Revision: 'rev_1.0'
F DEBUG   : ABI: 'arm'
F DEBUG   : pid: 29111, tid: 29282, name: SDLThread  >>> org.snowkit.snowbasic <<<
F DEBUG   : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
W debuggerd: type=1400 audit(0.0:3326): avc: denied { search } for name="org.snowkit.snowbasic" dev="dm-2" ino=1545295 scontext=u:r:debuggerd:s0 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0
F DEBUG   :     r0 00000000  r1 00007262  r2 00000006  r3 dcdef978
F DEBUG   :     r4 dcdef980  r5 dcdef930  r6 00000000  r7 0000010c
F DEBUG   :     r8 eefbf980  r9 eefbe680  sl dccf1000  fp e044d520
F DEBUG   :     ip 00000006  sp dcdef888  lr f6e24f85  pc f6e27374  cpsr 400e0010
F DEBUG   : 
F DEBUG   : backtrace:
F DEBUG   :     #00 pc 00042374  /system/lib/libc.so (tgkill+12)
F DEBUG   :     #01 pc 0003ff81  /system/lib/libc.so (pthread_kill+32)
F DEBUG   :     #02 pc 0001c73f  /system/lib/libc.so (raise+10)
F DEBUG   :     #03 pc 000198f1  /system/lib/libc.so (__libc_android_abort+34)
F DEBUG   :     #04 pc 000174b0  /system/lib/libc.so (abort+4)
F DEBUG   :     #05 pc 00679304  /data/app/org.snowkit.snowbasic-2/lib/arm/libsnow_basic.so (__gnu_cxx::__verbose_terminate_handler()+344)
F DEBUG   :     #06 pc 00631300  /data/app/org.snowkit.snowbasic-2/lib/arm/libsnow_basic.so (__cxxabiv1::__terminate(void (*)())+4)
F DEBUG   :     #07 pc 00631340  /data/app/org.snowkit.snowbasic-2/lib/arm/libsnow_basic.so (std::terminate()+16)
F DEBUG   :     #08 pc 00631700  /data/app/org.snowkit.snowbasic-2/lib/arm/libsnow_basic.so (__cxa_pure_virtual+24)
F DEBUG   :     #09 pc 0066c53c  /data/app/org.snowkit.snowbasic-2/lib/arm/libsnow_basic.so (execute_native_thread_routine+28)
F DEBUG   :     #10 pc 0003f883  /system/lib/libc.so (__pthread_start(void*)+30)
F DEBUG   :     #11 pc 00019f75  /system/lib/libc.so (__start_thread+6)
F DEBUG   : 
F DEBUG   : Tombstone written to: /data/tombstones/tombstone_01
E DEBUG   : AM write failed: Broken pipe
I WindowState: WIN DEATH: Window{8961fdf u0 org.snowkit.snowbasic/org.snowkit.snowbasic.AppActivity}
W WindowManager: Force-removing child win Window{13cdf65 u0 SurfaceView} from container Window{8961fdf u0 org.snowkit.snowbasic/org.snowkit.snowbasic.AppActivity}
I Zygote  : Process 29111 exited due to signal (6)

Debugging via Android studio with NDK debugging yields minimal help,
Because it's an abort, I can't get lldb or gdb (via android studio or otherwise) to break properly once it triggers. All other stepping through prior is fine until it does, but the code reaches the end of it's execution before crashing (note the code prints done from inside the app on return of the init call).

Due to the nature of the abort it also makes it difficult to search for help, and all the common thread related issues are (or should be) accounted for above.

I have noticed this verbose log in other peoples issues on this repo: V/GamesNativeSDK(12369): Attached to JVM on thread 1927939016 but I never see this in my logcat, the only line from the sdk is the above one about the jar file.

Any help is appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions