sqlcipher / android-database-sqlcipher

Android SQLite API based on SQLCipher
https://www.zetetic.net/sqlcipher/sqlcipher-for-android/
Other
2.73k stars 564 forks source link

After call SQLiteDatabase.loadLibs(mContext), throw exception SIGILL (signal SIGILL: illegal instruction) #548

Closed Lurkyli closed 3 years ago

Lurkyli commented 3 years ago

Expected Behavior

I want to integrate android-database-sqlcipher:4.4.3 into my smart TV app, and it works fine on android 4.4.2.

Actual Behavior

After SQLiteDatabase.loadLibs(mContext) was called, the exception SIGILL (signal SIGILL: illegal instruction) was thrown on an android 4.4.2 TV.

Steps to Reproduce

  1. Integrate android-database-sqlcipher:4.4.3 into a app;
  2. Launch the app on android 4.4.2 smart TV.

SQLCipher for Android version: android-database-sqlcipher:4.4.3

Are you able to reproduce this issue within the SQLCipher for Android test suite? No, but I meet the follow test failed:

05-28 08:52:12.070 7838-7892/net.zetetic.sqlcipher.test I/Zetetic: Running test:Encrypt Bytes Test 05-28 08:52:12.115 7838-7892/net.zetetic.sqlcipher.test W/dalvikvm: Unable to resolve superclass of Landroidx/room/RoomTrackingLiveData; (904) 05-28 08:52:12.115 7838-7892/net.zetetic.sqlcipher.test W/dalvikvm: Link of class 'Landroidx/room/RoomTrackingLiveData;' failed 05-28 08:52:12.120 7838-7892/net.zetetic.sqlcipher.test E/dalvikvm: Could not find class 'androidx.room.RoomTrackingLiveData', referenced from method androidx.room.InvalidationLiveDataContainer.create 05-28 08:52:12.120 7838-7892/net.zetetic.sqlcipher.test W/dalvikvm: VFY: unable to resolve new-instance 993 (Landroidx/room/RoomTrackingLiveData;) in Landroidx/room/InvalidationLiveDataContainer; 05-28 08:52:12.120 7838-7892/net.zetetic.sqlcipher.test D/dalvikvm: VFY: replacing opcode 0x22 at 0x0000 05-28 08:52:12.125 7838-7892/net.zetetic.sqlcipher.test W/dalvikvm: VFY: unable to find class referenced in signature (Landroidx/lifecycle/LiveData;) 05-28 08:52:12.130 7838-7892/net.zetetic.sqlcipher.test W/dalvikvm: VFY: unable to find class referenced in signature (Landroidx/lifecycle/LiveData;) 05-28 08:52:12.130 7838-7892/net.zetetic.sqlcipher.test W/dalvikvm: Unable to resolve superclass of Landroidx/room/RoomTrackingLiveData; (904) 05-28 08:52:12.130 7838-7892/net.zetetic.sqlcipher.test W/dalvikvm: Link of class 'Landroidx/room/RoomTrackingLiveData;' failed 05-28 08:52:12.135 7838-7892/net.zetetic.sqlcipher.test D/dalvikvm: DexOpt: unable to opt direct call 0x16a9 at 0x09 in Landroidx/room/InvalidationLiveDataContainer;.create 05-28 08:52:12.145 7838-7892/net.zetetic.sqlcipher.test D/dalvikvm: Trying to load lib /data/app-lib/net.zetetic.sqlcipher.test-2/libsqlcipher.so 0x4231b798 05-28 08:52:12.145 7838-7892/net.zetetic.sqlcipher.test D/dalvikvm: Shared lib '/data/app-lib/net.zetetic.sqlcipher.test-2/libsqlcipher.so' already loaded in same CL 0x4231b798 05-28 08:52:16.295 7838-7892/net.zetetic.sqlcipher.test I/Zetetic: java.lang.IllegalStateException: Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number. 05-28 08:52:16.295 7838-7892/net.zetetic.sqlcipher.test I/Zetetic: Running test:Encrypted Room Test

Additional information: My CPU info: Processor : ARMv7 Processor rev 3 (v7l) processor : 0 BogoMIPS : 1785.84

processor : 1 BogoMIPS : 1785.84

processor : 2 BogoMIPS : 1785.84

processor : 3 BogoMIPS : 1785.84

Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xc07 CPU revision : 3

Hardware : Madison Revision : 0020 Serial : 0000000000000000

ro.product.cpu.abi=armeabi-v7a ro.product.cpu.abi2=armeabi

My log: 05-27 17:47:23.080 24736-24736/com.. W/Settings: Setting android_id has moved from android.provider.Settings.System to android.provider.Settings.Secure, returning read-only value. 05-27 17:47:25.420 24736-24736/com.. D/dalvikvm: Trying to load lib /data/app-lib/com..-1/libsqlcipher.so 0x4202ec78 05-27 17:47:42.560 24736-24741/com.. I/dalvikvm: threadid=3: reacting to signal 3 05-27 17:47:46.840 24736-24736/com.. D/dalvikvm: Added shared lib /data/app-lib/com..-1/libsqlcipher.so 0x4202ec78 05-27 17:47:46.845 24736-24741/com.. I/dalvikvm: Wrote stack traces to '/data/anr/traces.txt'

developernotes commented 3 years ago

Hi @Lurkyli

It appears your Android TV is running Android OS 4.4.2, correct? That is API 19, however, Android Studio only offers down to API 21 when creating Android TV emulator's. I was unable to boot an Android TV emulator running API 21, however, I was able to run our test suite successfully on an Android TV emulator running API 22.

Screen Shot 2021-05-28 at 07 37 43

Are you able to run either your application, or the test suite on other Android OS TV versions, or are you limited to Android OS 4.4.2?

Lurkyli commented 3 years ago

Android-database-sqlcipher:4.4.3 works fine on other smart TV, eg: android 5.1/8.0 and another 4.4.4(api 19). I think my project maybe have some different config among them, and I'm investigating it.

Lurkyli commented 3 years ago

After I added my native module code into the sqlcipher-android-tests-master demo project, the issue was reproduced. There are the build.gradle files: The build.gradle in app module: apply plugin: 'com.android.application'

android { compileSdkVersion 30 buildToolsVersion "30.0.3"

defaultConfig { applicationId "net.zetetic.sqlcipher.test" minSdkVersion 19 targetSdkVersion 30 versionCode 500000 versionName "5.0.0" ndk { // 设置支持的SO库架构 abiFilters 'armeabi-v7a' } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } debug { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } }

dependencies { // For testing JAR-based distribution: // implementation files('libs/sqlcipher.jar')

// For testing local AAR packages: //implementation (name: 'android-database-sqlcipher-4.4.3-release', ext: 'aar')

// For testing on remote AAR references: implementation 'net.zetetic:android-database-sqlcipher:4.4.3@aar'

implementation "androidx.sqlite:sqlite:2.0.1"

// For Room tests: implementation "androidx.room:room-runtime:2.1.0" annotationProcessor "androidx.room:room-compiler:2.1.0" }

The build.gradle in my native module: plugins { id 'com.android.library' }

android { compileSdkVersion 30 buildToolsVersion "30.0.3"

defaultConfig {
    minSdkVersion 19
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    externalNativeBuild {
        cmake {
            cppFlags ""
            abiFilters 'armeabi-v7a'
        }
    }
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
    debug {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

externalNativeBuild {
    cmake {
        path "src/main/cpp/CMakeLists.txt"
        version "3.10.2"
    }
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

}

dependencies {

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

}

If I disabled the native build in my native module, it's ok.

Have you the debug release aar? I want to catch more detail log.

Thanks!

Lurkyli commented 3 years ago

This is the log: 05-31 15:11:41.345 1745-1751/net.zetetic.sqlcipher.test I/dalvikvm: Debugger is active 05-31 15:11:41.540 1745-1745/net.zetetic.sqlcipher.test I/System.out: Debugger has connected 05-31 15:11:41.540 1745-1745/net.zetetic.sqlcipher.test I/System.out: waiting for debugger to settle... 05-31 15:11:41.705 31330-31386/com.coocaa.screensaver D/dalvikvm: GC_EXPLICIT freed 47K, 11% free 5561K/6232K, paused 4ms+6ms, total 53ms 05-31 15:11:41.740 1745-1745/net.zetetic.sqlcipher.test I/System.out: waiting for debugger to settle... 05-31 15:11:41.940 1745-1745/net.zetetic.sqlcipher.test I/System.out: waiting for debugger to settle... 05-31 15:11:42.140 1745-1745/net.zetetic.sqlcipher.test I/System.out: waiting for debugger to settle... 05-31 15:11:42.340 1745-1745/net.zetetic.sqlcipher.test I/System.out: waiting for debugger to settle... 05-31 15:11:42.540 1745-1745/net.zetetic.sqlcipher.test I/System.out: waiting for debugger to settle... 05-31 15:11:42.560 6207-6224/com.tianci.appstore D/dalvikvm: GC_EXPLICIT freed 1294K, 34% free 8934K/13408K, paused 6ms+13ms, total 88ms 05-31 15:11:42.745 1745-1745/net.zetetic.sqlcipher.test I/System.out: waiting for debugger to settle... 05-31 15:11:42.795 6207-6224/com.tianci.appstore D/dalvikvm: GC_EXPLICIT freed 128K, 35% free 8828K/13408K, paused 6ms+11ms, total 80ms 05-31 15:11:42.945 1745-1745/net.zetetic.sqlcipher.test I/System.out: debugger has settled (1300) 05-31 15:11:42.985 1745-1745/net.zetetic.sqlcipher.test I/NativeInitializer: Before loadLibs 05-31 15:11:43.000 1745-1745/net.zetetic.sqlcipher.test D/dalvikvm: Trying to load lib /data/app-lib/net.zetetic.sqlcipher.test-1/libsqlcipher.so 0x423066a8 05-31 15:11:43.035 1002-1002/? I/tvos: AVG:0 05-31 15:11:43.035 1002-1002/? I/tvos: bSrcDetResult[2] == 0 ,preRes=0 05-31 15:11:43.325 31373-31454/com.coocaa.screensaver D/dalvikvm: GC_EXPLICIT freed <1K, 12% free 5747K/6476K, paused 5ms+8ms, total 54ms 05-31 15:11:43.850 1004-1322/? D/guard_bin: exist processed : /mnt/media_rw/sdcard0 05-31 15:11:43.850 1004-1322/? D/guard_bin: exist processed : /mnt/secure/asec 05-31 15:11:44.375 1002-1002/? I/tvos: AVG:0 05-31 15:11:44.375 1002-1002/? I/tvos: bSrcDetResult[23] == 0 ,preRes=0 05-31 15:11:44.715 1002-1002/? I/tvos: AVG:0 05-31 15:11:44.715 1002-1002/? I/tvos: bSrcDetResult[24] == 0 ,preRes=0 05-31 15:11:44.960 4352-4352/com.tianci.de D/dalvikvm: GC_FOR_ALLOC freed 512K, 12% free 4614K/5228K, paused 21ms, total 21ms 05-31 15:11:45.950 6207-6224/com.tianci.appstore D/dalvikvm: GC_EXPLICIT freed 6K, 35% free 8835K/13408K, paused 6ms+12ms, total 80ms 05-31 15:11:46.720 1002-1002/? I/tvos: AVG:0 05-31 15:11:46.720 1002-1002/? I/tvos: bSrcDetResult[2] == 0 ,preRes=0 05-31 15:11:46.850 1004-1322/? D/guard_bin: exist processed : /mnt/media_rw/sdcard0 05-31 15:11:46.850 1004-1322/? D/guard_bin: exist processed : /mnt/secure/asec 05-31 15:11:47.045 6207-6207/com.tianci.appstore I/MyAppOperationItemView: updateCurrentOperationIndex: isStop = trueisMyappShow = true 05-31 15:11:47.135 6207-6207/com.tianci.appstore I/MyAppOperationItemView: updateCurrentOperationIndex: isStop = trueisMyappShow = true 05-31 15:11:47.525 1976-2085/system_process W/ActivityManager: Launch timeout has expired, giving up wake lock! 05-31 15:11:47.525 1976-2085/system_process E/PowerManagerService: updateUserActivitySummaryLockedBySkyworth screenOffTimeout == -1, can not dream 05-31 15:11:47.575 1976-2046/system_process E/WindowManager: Starting window AppWindowToken{428587b0 token=Token{425719a8 ActivityRecord{42580990 u0 net.zetetic.sqlcipher.test/net.zetetic.activities.TestRunnerSelectionActivity t34}}} timed out 05-31 15:11:47.850 6207-6224/com.tianci.appstore D/dalvikvm: GC_EXPLICIT freed 17K, 35% free 8835K/13408K, paused 6ms+9ms, total 76ms 05-31 15:11:48.060 1002-1002/? I/tvos: AVG:0 05-31 15:11:48.060 1002-1002/? I/tvos: bSrcDetResult[23] == 0 ,preRes=0 05-31 15:11:48.400 1002-1002/? I/tvos: AVG:0 05-31 15:11:48.400 1002-1002/? I/tvos: bSrcDetResult[24] == 0 ,preRes=0 05-31 15:11:49.850 1004-1322/? D/guard_bin: exist processed : /mnt/media_rw/sdcard0 05-31 15:11:49.850 1004-1322/? D/guard_bin: exist processed : /mnt/secure/asec 05-31 15:11:50.405 1002-1002/? I/tvos: AVG:0 05-31 15:11:50.405 1002-1002/? I/tvos: bSrcDetResult[2] == 0 ,preRes=0 05-31 15:11:51.745 1002-1002/? I/tvos: AVG:0 05-31 15:11:51.745 1002-1002/? I/tvos: bSrcDetResult[23] == 0 ,preRes=0 05-31 15:11:52.085 1002-1002/? I/tvos: AVG:0 05-31 15:11:52.085 1002-1002/? I/tvos: bSrcDetResult[24] == 0 ,preRes=0

Lurkyli commented 3 years ago

I think it's a debug environment issue, and the Android-database-sqlcipher works well on release environment. The issue duplicate with https://github.com/sqlcipher/android-database-sqlcipher/issues/269.

Thanks!

developernotes commented 3 years ago

Hi @Lurkyli

Thank you for the update, we are happy to hear SQLCipher for Android is working well for you.