Skip to content

net.sqlcipher.database.SQLiteDatabase.native_execSQL #555

Closed
@allenhsu-17live

Description

@allenhsu-17live

Expected Behavior

No crash

Actual Behavior

crash happen from firebase

net.sqlcipher.database.SQLiteDatabase.native_execSQL (SQLiteDatabase.java)
net.sqlcipher.database.SQLiteDatabase.execSQL (SQLiteDatabase.java:2439)
net.sqlcipher.database.SQLiteDatabase.beginTransactionWithListenerInternal (SQLiteDatabase.java:3052)
net.sqlcipher.database.SQLiteDatabase.beginTransactionWithListener (SQLiteDatabase.java:777)
net.sqlcipher.database.SQLiteDatabase.beginTransaction (SQLiteDatabase.java:748)
androidx.room.InvalidationTracker.syncTriggers (InvalidationTracker.java:498)
androidx.room.InvalidationTracker.syncTriggers (InvalidationTracker.java:538)
androidx.room.InvalidationTracker.addObserver (InvalidationTracker.java:275)
androidx.room.MultiInstanceInvalidationClient$3.run (MultiInstanceInvalidationClient.java:124)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
java.lang.Thread.run (Thread.java:764)

I guess the rootcase on here

void syncTriggers(SupportSQLiteDatabase database) {
        if (database.inTransaction()) {
            // we won't run this inside another transaction.
            return;
        }
        try {
            // This method runs in a while loop because while changes are synced to db, another
            // runnable may be skipped. If we cause it to skip, we need to do its work.
            while (true) {
                Lock closeLock = mDatabase.getCloseLock();
                closeLock.lock();
                try {
                    // there is a potential race condition where another mSyncTriggers runnable
                    // can start running right after we get the tables list to sync.
                    final int[] tablesToSync = mObservedTableTracker.getTablesToSync();
                    if (tablesToSync == null) {
                        return;
                    }
                    final int limit = tablesToSync.length;
                    database.beginTransaction();
                    try {
                        for (int tableId = 0; tableId < limit; tableId++) {
                            switch (tablesToSync[tableId]) {
                                case ObservedTableTracker.ADD:
                                    startTrackingTable(database, tableId);
                                    break;
                                case ObservedTableTracker.REMOVE:
                                    stopTrackingTable(database, tableId);
                                    break;
                            }
                        }
                        database.setTransactionSuccessful();
                    } finally {
                        database.endTransaction();
                    }
                    mObservedTableTracker.onSyncCompleted();
                } finally {
                    closeLock.unlock();
                }
            }
        } catch (IllegalStateException | SQLiteException exception) {
            // may happen if db is closed. just log.
            Log.e(Room.LOG_TAG, "Cannot run invalidation tracker. Is the db closed?",
                    exception);
        }
    }

the roomdata base catch SQLiteException exception, but the full class is
android.database.sqlite.SQLiteException
But when I use net.sqlcipher.database, will throw this exception net.sqlcipher.database.SQLiteException
It's different class. so Room can't try catch that. could you try to fix it?

Steps to Reproduce

  1. Use the RoomDataBase
  2. enableMultiInstanceInvalidation (Because we need multi process)

SQLCipher version (can be identified by executing PRAGMA cipher_version;):

SQLCipher for Android version:
4.4.3
Are you able to reproduce this issue within the SQLCipher for Android test suite?
I can't, just only firebase report

Note: If you are not posting a specific issue for the SQLCipher library, please post your question to the SQLCipher discuss site. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleThis issue lacks recent activity.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions