Using SQLCipher on Android N Preview leads to segfault

Launching an app using SQLCipher 3.3.1-2 on a device running Android N Preview (in this case a Pixel C) leads to an immediate Segmentation Fault of the the system.

The same app has been working fine on Android M.

Here’s the logcat output:

03-10 12:06:22.981 14193-14193/com.example.app W/linker: library "libutils.so" ("/system/lib/libutils.so") needed or dlopened by "/data/app/com.example.app-1/lib/arm/libsqlcipher_android.so" is not accessible for the namespace "classloader-namespace" - the access is temporarily granted as a workaround for http://b/26394120 03-10 12:06:22.981 14193-14193/com.example.app W/linker: library "libcutils.so" ("/system/lib/libcutils.so") needed or dlopened by "/data/app/com.example.app-1/lib/arm/libsqlcipher_android.so" is not accessible for the namespace "classloader-namespace" - the access is temporarily granted as a workaround for http://b/26394120 03-10 12:06:22.994 14193-14193/com.example.app W/linker: library "libnativehelper.so" ("/system/lib/libnativehelper.so") needed or dlopened by "/data/app/com.example.app-1/lib/arm/libdatabase_sqlcipher.so" is not accessible for the namespace "classloader-namespace" - the access is temporarily granted as a workaround for http://b/26394120 03-10 12:06:22.994 14193-14193/com.example.app W/linker: library "libandroid_runtime.so" ("/system/lib/libandroid_runtime.so") needed or dlopened by "/data/app/com.example.app-1/lib/arm/libdatabase_sqlcipher.so" is not accessible for the namespace "classloader-namespace" - the access is temporarily granted as a workaround for http://b/26394120 03-10 12:06:22.995 14193-14193/com.example.app W/linker: library "libbinder.so" ("/system/lib/libbinder.so") needed or dlopened by "/data/app/com.example.app-1/lib/arm/libdatabase_sqlcipher.so" is not accessible for the namespace "classloader-namespace" - the access is temporarily granted as a workaround for http://b/26394120 03-10 12:06:23.208 14193-14193/com.example.app I/Database: JNI_OnLoad called 03-10 12:06:23.208 14193-14193/com.example.app I/Database: JNI_OnLoad register methods 03-10 12:06:22.981 14193-14193/com.example.app W/linker: library "libutils.so" ("/system/lib/libutils.so") needed or dlopened by "/data/app/com.example.app-1/lib/arm/libsqlcipher_android.so" is not accessible for the namespace "classloader-namespace" - the access is temporarily granted as a workaround for http://b/26394120 03-10 12:06:22.981 14193-14193/com.example.app W/linker: library "libcutils.so" ("/system/lib/libcutils.so") needed or dlopened by "/data/app/com.example.app-1/lib/arm/libsqlcipher_android.so" is not accessible for the namespace "classloader-namespace" - the access is temporarily granted as a workaround for http://b/26394120 03-10 12:06:22.994 14193-14193/com.example.app W/linker: library "libnativehelper.so" ("/system/lib/libnativehelper.so") needed or dlopened by "/data/app/com.example.app-1/lib/arm/libdatabase_sqlcipher.so" is not accessible for the namespace "classloader-namespace" - the access is temporarily granted as a workaround for http://b/26394120 03-10 12:06:22.994 14193-14193/com.example.app W/linker: library "libandroid_runtime.so" ("/system/lib/libandroid_runtime.so") needed or dlopened by "/data/app/com.example.app-1/lib/arm/libdatabase_sqlcipher.so" is not accessible for the namespace "classloader-namespace" - the access is temporarily granted as a workaround for http://b/26394120 03-10 12:06:22.995 14193-14193/com.example.app W/linker: library "libbinder.so" ("/system/lib/libbinder.so") needed or dlopened by "/data/app/com.example.app-1/lib/arm/libdatabase_sqlcipher.so" is not accessible for the namespace "classloader-namespace" - the access is temporarily granted as a workaround for http://b/26394120 03-10 12:06:23.208 14193-14193/com.example.app I/Database: JNI_OnLoad called 03-10 12:06:23.208 14193-14193/com.example.app I/Database: JNI_OnLoad register methods 03-10 12:06:23.505 14193-14265/com.example.app A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 14265 (Thread-7) 03-10 12:06:23.520 14266-14266/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 03-10 12:06:23.520 14266-14266/? A/DEBUG: Build fingerprint: 'google/ryu/dragon:N/NPC56P/2659757:user/release-keys' 03-10 12:06:23.520 14266-14266/? A/DEBUG: Revision: '0' 03-10 12:06:23.520 14266-14266/? A/DEBUG: ABI: 'arm' 03-10 12:06:23.520 14266-14266/? A/DEBUG: pid: 14193, tid: 14265, name: Thread-7 >>> com.example.app <<< 03-10 12:06:23.521 14266-14266/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 03-10 12:06:23.521 14266-14266/? A/DEBUG: r0 00000000 r1 00000000 r2 00000000 r3 000000f2 03-10 12:06:23.521 14266-14266/? A/DEBUG: r4 00000000 r5 d90800f2 r6 d94fdda8 r7 f66c0008 03-10 12:06:23.521 14266-14266/? A/DEBUG: r8 00000004 r9 00000000 sl d94fde20 fp db511f00 03-10 12:06:23.521 14266-14266/? A/DEBUG: ip ebf40cc0 sp d94fdd88 lr ebf35115 pc ebf33d62 cpsr 600f0030 03-10 12:06:23.528 14266-14266/? A/DEBUG: #00 pc 0000dd62 /system/lib/libutils.so (android::SharedBuffer::acquire() const+3) 03-10 12:06:23.528 14266-14266/? A/DEBUG: #01 pc 0000f111 /system/lib/libutils.so 03-10 12:06:23.528 14266-14266/? A/DEBUG: #02 pc 0000f183 /system/lib/libutils.so (android::String16::String16(char const*, unsigned int)+8) 03-10 12:06:23.528 14266-14266/? A/DEBUG: #03 pc 0000853b /data/app/com.example.app-1/lib/arm/libdatabase_sqlcipher.so 03-10 12:06:23.528 14266-14266/? A/DEBUG: #04 pc 00120af9 /system/lib/libart.so (art_quick_generic_jni_trampoline+40) 03-10 12:06:23.528 14266-14266/? A/DEBUG: #05 pc 0011c2c1 /system/lib/libart.so (art_quick_invoke_stub_internal+64) 03-10 12:06:23.528 14266-14266/? A/DEBUG: #06 pc 00474a07 /system/lib/libart.so (art_quick_invoke_stub+190) 03-10 12:06:23.528 14266-14266/? A/DEBUG: #07 pc 001233e3 /system/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+174) 03-10 12:06:23.528 14266-14266/? A/DEBUG: #08 pc 0023721d /system/lib/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*, art::JValue*)+152) 03-10 12:06:23.528 14266-14266/? A/DEBUG: #09 pc 002378b3 /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+546) 03-10 12:06:23.528 14266-14266/? A/DEBUG: #10 pc 0046e3ad /system/lib/libart.so (MterpInvokeDirect+164) 03-10 12:06:23.528 14266-14266/? A/DEBUG: #11 pc 0010f294 /system/lib/libart.so (ExecuteMterpImpl+14484) 03-10 12:06:23.528 14266-14266/? A/DEBUG: #12 pc 00231d43 /system/lib/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue)+238) 03-10 12:06:23.528 14266-14266/? A/DEBUG: #13 pc 002320d5 /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*, art::JValue*)+116) 03-10 12:06:23.528 14266-14266/? A/DEBUG: #14 pc 0023790b /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+634) 03-10 12:06:23.528 14266-14266/? A/DEBUG: #15 pc 0046de7d /system/lib/libart.so (MterpInvokeVirtual+456) 03-10 12:06:23.528 14266-14266/? A/DEBUG: #16 pc 0010f194 /system/lib/libart.so (ExecuteMterpImpl+14228) 03-10 12:06:23.528 14266-14266/? A/DEBUG: #17 pc 00231d43 /system/lib/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue)+238) 03-10 12:06:23.528 14266-14266/? A/DEBUG: #18 pc 00232021 /system/lib/libart.so (art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*)+60) 03-10 12:06:23.528 14266-14266/? A/DEBUG: #19 pc 00467ee5 /system/lib/libart.so (artQuickToInterpreterBridge+916) 03-10 12:06:23.529 14266-14266/? A/DEBUG: #20 pc 00120b73 /system/lib/libart.so (art_quick_to_interpreter_bridge+34) 03-10 12:06:23.529 14266-14266/? A/DEBUG: #21 pc 017d57bb /system/framework/arm/boot-framework.oat (offset 0x16ea000)

Please let me know if you need more information.

Hello @mimiks

Thank you for your early report of SQLCipher for Android on Android N. We have a Pixel C on order and hope to begin further testing/debugging on device once we receive it. Take care!

Having a similar Experience on a Nexus 6

03-10 16:17:18.196 8021-8021/? A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 8021 (pp.test)
03-10 16:17:18.271 8154-8154/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-10 16:17:18.271 8154-8154/? A/DEBUG: Build fingerprint: 'google/shamu/shamu:N/NPC56P/2659757:user/release-keys’
03-10 16:17:18.271 8154-8154/? A/DEBUG: Revision: '0’
03-10 16:17:18.271 8154-8154/? A/DEBUG: ABI: 'arm’
03-10 16:17:18.272 8154-8154/? A/DEBUG: pid: 8021, tid: 8021, name: pp.test >>> com.app.test <<<
03-10 16:17:18.272 8154-8154/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
03-10 16:17:18.272 8154-8154/? A/DEBUG: r0 00000000 r1 00000000 r2 00000000 r3 96680000
03-10 16:17:18.272 8154-8154/? A/DEBUG: r4 00000000 r5 96680055 r6 bee7bad8 r7 95e11820
03-10 16:17:18.272 8154-8154/? A/DEBUG: r8 12caf6c8 r9 b1c04f00 sl bee7bb40 fp b1c04f00
03-10 16:17:18.275 916-934/? I/WindowManager: Destroying surface Surface(name=Starting com.app.test) called by com.android.server.wm.WindowStateAnimator.destroySurface:1738 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:816 com.android.server.wm.WindowState.removeLocked:1343 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2302
03-10 16:17:18.272 8154-8154/? A/DEBUG: ip 98c8dcc0 sp bee7ba98 lr 98c820f1 pc 98c80d52 cpsr 800b0030
03-10 16:17:18.284 8154-8154/? A/DEBUG: #00 pc 0000dd52 /system/lib/libutils.so (android::SharedBuffer::acquire() const+3)
03-10 16:17:18.284 8154-8154/? A/DEBUG: #01 pc 0000f0ed /system/lib/libutils.so
03-10 16:17:18.285 8154-8154/? A/DEBUG: #02 pc 0000f15f /system/lib/libutils.so (android::String16::String16(char const*, unsigned int)+8)
03-10 16:17:18.285 8154-8154/? A/DEBUG: #03 pc 0000891b /data/app/com.app.test-1/lib/arm/libdatabase_sqlcipher.so
03-10 16:17:18.285 8154-8154/? A/DEBUG: #04 pc 001209f9 /system/lib/libart.so (art_quick_generic_jni_trampoline+40)
03-10 16:17:18.285 8154-8154/? A/DEBUG: #05 pc 00007b9b /dev/ashmem/dalvik-jit-code-cache (deleted)

Hello @markatrova

What Android OS are you running on your Nexus 6? Are you able to run the SQLCipher for Android test suite?

Here’s the output of the test suite when running on Android N preview:

Passed: 32 Failed: 10
Unicode (ICU) TestCipher Migrate TestrawExecSQL TestAES-128 Bit Cipher TestMigrate Database 1.x to Current TestPRAGMA cipher_version TestImport Unencrypted Database TestExport to Unencrypted DatabaseQuery Non-Encrypted Database TestSoundex Test

The test suite works fine on earlier android versions (no failed tests).

Hello @mimiks

Thank you for providing an update, we plan to look into this.

It looks like an issue with the changes in how Android N handles NDK http://developer.android.com/preview/behavior-changes.html#ndk

when I launch our app I get nice warnings about 'Detected problems with app native libraries (please consult log for detail).
libsqlcipher_android.so. unauthorized
libutils.so
libnativehelper.so
libandroid_runtime.so
libdatabase_sqlcipher.so