SQLite Forum

Local Database is not creating in NDK android app
Login

Local Database is not creating in NDK android app

(1) By Bhumika (bhumim92) on 2020-09-21 07:28:02 [link] [source]

Hi team,

I am working on 32bit to 64bit migration in NDK applicaiton. My Project following below libraries: libssl.so, libcrypto.so (FIPS compatible), libc++_shared.so, libart.so, libcrashlytics.so, libz.so, libcrashlytics-envelope.so and libcurl.a.

  1. Minimum SDk support - 24 (Android API)
  2. CMake minimum required version - 3.4.1

After migrating project to 64bit device (ABI: arm64-v8a) support, the application is crashing while creating local database in Android. I am not using any external library or '.so' libs. I am using local database Sqlite3 of android.jar (extended class name - SqliteOpenHelper).

Application is crashing in Samsung and Realme devices:

  1. Samsung A7
  2. Samsung M40
  3. Samsung S9
  4. Samsung S10
  5. Realme C2

But applicaiton is working fine in One plus(7, 7pro, 5) and Nokia 6.1 plus.

I have tried to create database at other location but it's not creating

Error: Fatal signal 11 (SIGSEGV), code 2, fault addr 0x766908c0 in tid 9716 , pid 9716

When I checked for 32bit, it's working fine and database is created at /data/data/<app package>/database/<database name>

Is there any compatibility issue?

Please help me. Thanks!

(2) By Simon Slavin (slavin) on 2020-09-21 12:24:37 in reply to 1 [link] [source]

Don't know enough about Android to help, but can you list the versions of Android running on the platforms which work and don't work ? You listed these:

Crashes on: 1. Samsung A7 2. Samsung M40 3. Samsung S9 4. Samsung S10 5. Realme C2 Works on: One plus(7, 7pro, 5) and Nokia 6.1 plus.

If there's anything else obvious which divides the two platforms, please mention that too.

(3) By Bhumika (bhumim92) on 2020-09-21 13:25:50 in reply to 2 [link] [source]

App working on below Devices
Device name    Version	Processor
Nokia 6.1 plus	10	6xx
One plus 5	10	8xx
One Plus 7 Pro	10	8xx
One Plus 7	10	8xx

But in the below devices, the app is not working

Device name   Version	Processor
Samsung M40	8	6xx
Redmi Note 5	8	6xx
Samsung S10 	10	9xx
Samsung S9	9	9xx
Samsung Galaxy	8	Old

This is what I investigate. There is no memory size issue. Samsung S10 and Nokia 6.1 plus having same RAM size.

I am stuck here from last two weeks. I reached out Samsung community but they haven't changed at kernel level architecture.

(4) By Simon Slavin (slavin) on 2020-09-22 12:26:04 in reply to 3 [source]

Thank you for your post with platform details. If the S10 wasn't in there I would suggest a difference between the driver used with Android 10 and the one used with older versions.

Since your post contains no obvious clues we progress to more difficult and annoying questions. Are you able to get the result of SELECT sqlite_version() from each of the platforms above ? This should return a 1 row 1 field table.

Almost all SIGSEGV crashes come when some part of the application is writing over memory that SQLite thinks it owns. This can be a result of faulty memory handling, releasing a SQLite handle then trying to use it, or other reasons. It can be difficult to debug.

Can you tell us which SQLite call your application is crashing on ? What is SQLite trying to do when it crashes ? Are all crashes at the same point in your app or does it just crash randomly ?

Are you able to post a crash dump, a trace, or any other longer report about the crash ? You can, of course, edit this text to remove any confidential information.

(5) By Bhumika (bhumim92) on 2020-09-23 07:50:02 in reply to 4 [link] [source]

Yes, I tried to know version and it's 3.19.4. Application is crashing while calling getReadableDatabase() method of SqliteDatabase. So I debugged and found that database is not created on /data/data/project-package/database path.

Also, project trying to access below native libraries libandroid_runtime.so, libopenjdk.so libart.so libjavacore.so libbinder.so

App is crashing at same place everytime.

Crash dump

#00 0x0000000000002110 /dev/ashmem/dalvik-non moving space (deleted) (offset 0x2f19000)

#01 0x000000000000e0ec /system/lib64/libEGL.so (android::egl_cache_t::loadBlobCacheLocked()+96)

#02 0x000000000000e028 /system/lib64/libEGL.so (android::egl_cache_t::getBlob(void const*, long, void*, long)+140)

#03 0x00000000001c2270 /system/vendor/lib64/egl/libGLESv2_adreno.so (EsxShader::Compile(EsxContext*, int)+292)

(6) By Simon Slavin (slavin) on 2020-09-23 12:40:24 in reply to 5 [link] [source]

Thanks for the crash dump and other information.

Your problem appears to be with the Android shim for SQLite, not with SQLite itself. Both SqliteDatabase and getReadableDatabase() are parts of the Android shim, and no element of your crash dump mentions anything which is part of SQLite itself. There's nothing there that even an expert on SQLite can help with.

I would post on an Android forum, looking for people familiar with SqliteDatabase and/or libEGL. Your crash dump, and the list of models which do and don't work should be especially useful. Good luck.