Catch native crash: signal 7 (SIGBUS), code 2 (BUS

2019-08-01 04:01发布

问题:

On my Google Play Console I've got some reports for an application (FYI, it also uses JNI). This is the backtrace:

  native: pc 00000000002c0536  /system/lib/libart.so (_ZN3artL16Unsafe_putDoubleEP7_JNIEnvP8_jobjectS3_xd+31)
  native: pc 0000000073bb9609  /data/dalvik-cache/arm/system@framework@boot.oat

I am not able to catch it with any crash reporting system (Google Analytics, Crashlytics) and of course have no clue on how to reproduce it.

Interestingly, the devices affected for most are the ones from Motorola Moto G series and mid-aged Samsung Galaxy's.

The problem looks like to be outside from my application but I still would like to know which part of my code causes it so I can try a workaround to make it also work on those devices. Is it possible to spot the problem without having physically the device?

Gradle.build

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 294
        versionName "1.6.268"
        vectorDrawables.useSupportLibrary = true
        externalNativeBuild {
            ndkBuild {
                arguments "APP_STL:=gnustl_static"
            }
        }
    }

    dexOptions {
        javaMaxHeapSize "12g"
        jumboMode true
    }

    applicationVariants.all { variant ->
        variant.resValue "string", "versionName", variant.versionName
    }

    buildTypes {
        release {
            debuggable false
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.releaseConfig
            externalNativeBuild {
                ndkBuild {
                    cFlags "-DDEBUG_MODE=0"
                }
            }
        }
        debug {
            debuggable true
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            externalNativeBuild {
                ndkBuild {
                    cFlags "-DDEBUG_MODE=1"
                }
            }
        }
    }

    externalNativeBuild {
        ndkBuild {
            path 'src/main/jni/Android.mk'
        }
    }
    return void
}

Gradle version is 2.3.3 and also Android Studio 2.3.3.

Digging inside the old crash report section of Google Play Console, I found that it displays the full native crash data:

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
LineageOS Version: 'unknown'
Build fingerprint: 'samsung/j5lteub/j5lte:6.0.1/MMB29M/J500MUBU1BQH2:user/release-keys'
Revision: '5'
ABI: 'arm'
pid: 10935, tid: 11080, name: glide-source-th  >>> com. <<<
signal 7 (SIGBUS), code 2 (BUS_ADRERR), fault addr 0x902d8000
    r0 a4b3a670  r1 9385e5ec  r2 902d8000  r3 00000000
    r4 00000075  r5 70edc0cc  r6 902d8000  r7 00000000
    r8 00000063  r9 94903f00  sl 0000001b  fp 00000075
    ip b0052537  sp 9385e5e0  lr 73cc09a3  pc b0052536  cpsr 600d0030

backtrace:
    #00 pc 002c0536  /system/lib/libart.so (_ZN3artL16Unsafe_putDoubleEP7_JNIEnvP8_jobjectS3_xd+31)
    #01 pc 73cc09a1  /data/dalvik-cache/arm/system@framework@boot.oat (offset 0x283e000)

This would mean that it's not about my own code, not entirely at least, in fact you can see the process name is glide-source-th, yes, Glide. So much for today, I will keep it updated once I get in touch with Glide support (see GitHub issue).