Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File is not a database (code 26) crash after calling changePassword() #22

Open
mustafa-antonio opened this issue Nov 2, 2023 · 6 comments

Comments

@mustafa-antonio
Copy link

mustafa-antonio commented Nov 2, 2023

(26) statement aborts at 8: [SELECT * FROM note] file is not a database
--------- beginning of crash
com.example.sqlcipher_test           E  exception: file is not a database (code 26); query: SELECT * FROM note
 com.example.sqlcipher_test           E  FATAL EXCEPTION: main
Process: com.example.sqlcipher_test, PID: 21229
android.database.sqlite.SQLiteException: file is not a database (code 26)
at net.zetetic.database.sqlcipher.SQLiteConnection.nativeExecuteForCursorWindow(Native Method)                                                                                                    	at net.zetetic.database.sqlcipher.SQLiteConnection.executeForCursorWindow(SQLiteConnection.java:929)                                                                                                    	at net.zetetic.database.sqlcipher.SQLiteSession.executeForCursorWindow(SQLiteSession.java:871)
at net.zetetic.database.sqlcipher.SQLiteQuery.fillWindow(SQLiteQuery.java:68)
at net.zetetic.database.sqlcipher.SQLiteCursor.fillWindow(SQLiteCursor.java:196)
at net.zetetic.database.sqlcipher.SQLiteCursor.getCount(SQLiteCursor.java:135)
at com.example.sqlcipher_test.db.NoteDao_Impl$3.call(NoteDao_Impl.java:92)
at com.example.sqlcipher_test.db.NoteDao_Impl$3.call(NoteDao_Impl.java:84)
at androidx.room.CoroutinesRoom$Companion$execute$4$job$1.invokeSuspend(CoroutinesRoom.kt:87)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)

Looks like changePassword() does something incorrectly and throws this error when we call Room DAO query after. Happens in my production app and could be reproduced in sample project I attached to this issue (tested on Pixel 6a emulator with Android 14).

sqlciphertest.zip

Unless I'm missing some steps when performing password change? Issue appears in 4.5.4 & 4.5.5 version (possibly earlier versions too but haven't checked them).

Issue doesn't appear in legacy counterpart android-database-sqlcipher (4.5.4).

@developernotes
Copy link
Member

Hi @mustafa-antonio,

Thank you for your report and sample project, we will look into this and share our feedback once reviewed.

@anhndt3
Copy link

anhndt3 commented Nov 24, 2023

@developernotes is there any update on this? We've met the similar crash from android-database-sqlcipher like https://discuss.zetetic.net/t/fatal-exception-net-sqlcipher-database-sqliteexception-file-is-not-a-database-while-compiling-select-count-from-sqlite-master/4675
We plan to update the library and a bit worry to see this again here.

@developernotes
Copy link
Member

developernotes commented Nov 27, 2023

Hello @mustafa-antonio,

I have pushed up a fix, and unit test to address the issue of changing a password while using the Room API. The issue was the non-primary connection was not being closed following the rekey operation on the primary connection. Your subsequent query following the rekey would run using the non-primary connection which was previously keyed with the originating, now incorrect password. The fix is here and will be included in our next public release. In the interim, you can close and reopen your connection during a password change event. Thank you again for providing a recreation scenario.

@developernotes
Copy link
Member

Hi @anhndt3,

Are you able to provide an isolated recreation of the behavior you are seeing? If so, we would be happy to investigate the issue further. If you are using android-database-sqlcipher, you might consider adding a separate recreation test within the test suite.

@anhndt3
Copy link

anhndt3 commented Nov 29, 2023

Thanks for replying and pushing fix up, I am updating the library, haven't got the issue so far, just wonder the same issue still occurs or not. I will let you know if there's problem and reproduce sample.

@mustafa-antonio
Copy link
Author

@developernotes thanks for letting me know. Will check that out in next week after holidays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants