-
Notifications
You must be signed in to change notification settings - Fork 576
Description
Expected Behavior
Application doesn't crash while creating a database.
Actual Behavior
Application crashes while creating a database for few devices.
devices(Android OS)
LM-V510N(Android 10), LM0G910N(Android 10), LM-V500N(Android 10), LM-v409N(Android 10), SM-G965N(Android 10), SM-N971N(Android 11), LM-G900N(Android 11)
//we changed package name to sample
net.sqlcipher.database.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master;
at net.sqlcipher.database.SQLiteCompiledSql.native_compile(SQLiteCompiledSql.java)
at net.sqlcipher.database.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:89)
at net.sqlcipher.database.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:62)
at net.sqlcipher.database.SQLiteProgram.<init>(SQLiteProgram.java:91)
at net.sqlcipher.database.SQLiteQuery.<init>(SQLiteQuery.java:48)
at net.sqlcipher.database.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:60)
at net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:2016)
at net.sqlcipher.database.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1902)
at net.sqlcipher.database.SQLiteDatabase.keyDatabase(SQLiteDatabase.java:2669)
at net.sqlcipher.database.SQLiteDatabase.openDatabaseInternal(SQLiteDatabase.java:2599)
at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1247)
at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1322)
at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:166)
at net.sqlcipher.database.SupportHelper.getWritableDatabase(SupportHelper.java:83)
at androidx.room.RoomDatabase.inTransaction(RoomDatabase.java:476)
at androidx.room.RoomDatabase.assertNotSuspendingTransaction(RoomDatabase.java:281)
at androidx.room.RoomDatabase.query(RoomDatabase.java:324)
at androidx.room.RoomDatabase.query(RoomDatabase.java:311)
at com.sample.database.dao.SampleDao_Impl$11.compute(SampleDao_Impl.java:979)
at com.sample.database.dao.SampleDao_Impl$11.compute(SampleDao_Impl.java:965)
at androidx.lifecycle.ComputableLiveData$2.run(ComputableLiveData.java:101)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Steps to Reproduce
- Using room database (room version: 2.2.5)
- There is no database files before/after it happens. (we found out that it starts to happening at first launch.)
- application crashes when it tries to a create database with passcode
passcode is constant value like this: "3f150cd4-531f-30b1-be94-010be52117cb".toCharArray()
Here are my sample codes
// application
class SampleApp: Application() {
// we use this database with repository
private val sampleDatabase by lazy { SampleDataBase.getInstance(this) }
// this is a custom repository to query a database
val databaseRepository by lazy {
DatabaseRepository(sampleDatabase)
}
}
// database
abstract class SampleDatabase: RoomDatabase() {
abstract fun sampleDao(): SampleDao
companion object {
private var INSTANCE: SampleDatabase? = null
fun getInstance(context: Context): Sample Database {
return INSTANCE ?: synchronized(this) {
val instance = buildDatabase(context, passCode) // passCodes is constant value
INSTANCE = instance
instance
}
private fun buildDatabase(context:Context, passCode: CharArray): SampleDatabase {
val encryptionFactory = SupportFactory(SQLiteDatabase.getBytes(passCode))
return Room.databaseBuilder(
context.applicationContext,
SampleDatabase::class.java,
"sampledatabase.db"
)
.openHelperFactory(encryptionFactory)
.fallbackToDestructiveMigration()
.build()
}
}
}
SQLCipher version (can be identified by executing PRAGMA cipher_version;): 4.4.1 community
SQLCipher for Android version: 4.4.1
Are you able to reproduce this issue within the SQLCipher for Android test suite?
No, I couldn't reproduce when I try to test with my app and test suite app.
(Crash didn't occur for the same device models when I tested.)
It happens on released application for only few devices. However, once application crashes, it keeps happening until reinstalling app or clearing app datas.
I am wondering if there is anything I can do to fix this crash.