Skip to content

Repetitive crashes on 4.5.3: net.sqlcipher.CursorWindow.<init> & native_init #618

Open
@cokeperez

Description

@cokeperez

A few weeks ago we upgraded the version of SQLCipher in our application from 4.5.1 to 4.5.3. Since we updated the SQLCipher version, we are receiving dozens of crashes related to cursors on a daily basis.

Some info about the problem:

  • Queries and related code have not been modified for years.
  • The cursors are initialized and closed correctly on every query.
  • The crashes occur on different queries and in random situations.
  • In general, queries are simple, projecting a few columns and one or a few rows.
  • We have not been able to reproduce it.
  • We have used previous versions of SQLiteCipher for several years with the same code and barely 5-10 such crashes came in several months.

The two crashes that happen are:

net.sqlcipher.CursorWindow.<init> (two different causes)

85% on Android 4 (although this version only accounts for 20% of our network). These users on API19 (Android 4.4.2 and 4.4.4.4) all have older Samsung devices (Galaxy Tab 3/4/E). The remaining 15% are split between Android 9, 10 and 11, so the problem is not unique to Android 4 but does seem to be more prevalent on this version.

Caused by android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. 
       at android.database.CursorWindow.<init>(CursorWindow.java:109)
       at android.database.CursorWindow.<init>(CursorWindow.java:100)
       at android.database.CursorWindow.<init>(CursorWindow.java:131)
       at net.sqlcipher.CursorWindow.<init>(CursorWindow.java:67)
       at net.sqlcipher.database.SQLiteCursor.fillWindow(SQLiteCursor.java:301)
       at net.sqlcipher.database.SQLiteCursor.getCount(SQLiteCursor.java:292)
       at net.sqlcipher.AbstractCursor.moveToPosition(AbstractCursor.java:178)
       at net.sqlcipher.AbstractCursor.moveToFirst(AbstractCursor.java:222)
       at android.database.CursorWrapper.moveToFirst(CursorWrapper.java:65)
       at org.frogtek.database.wrapper.Cursor.moveToFirst(Cursor.java:50)
       ...
       ...
Caused by android.database.CursorWindowAllocationException: Could not allocate CursorWindow '<unnamed>' of size 2097152 due to error -12.
       at android.database.CursorWindow.nativeCreate(CursorWindow.java)
       at android.database.CursorWindow.<init>(CursorWindow.java:139)
       at android.database.CursorWindow.<init>(CursorWindow.java:120)
       at android.database.CursorWindow.<init>(CursorWindow.java:162)
       at net.sqlcipher.CursorWindow.<init>(CursorWindow.java:67)
       at net.sqlcipher.database.SQLiteCursor.fillWindow(SQLiteCursor.java:301)
       at net.sqlcipher.database.SQLiteCursor.getCount(SQLiteCursor.java:292)
       at net.sqlcipher.AbstractCursor.moveToPosition(AbstractCursor.java:178)
       at net.sqlcipher.AbstractCursor.moveToFirst(AbstractCursor.java:222)
       at android.database.CursorWrapper.moveToFirst(CursorWrapper.java:75)
       ...
       ...

net.sqlcipher.CursorWindow.native_init

99% on Android 4

Fatal Exception: java.lang.IllegalStateException: Couldn't init cursor window
       at net.sqlcipher.CursorWindow.native_init(CursorWindow.java)
       at net.sqlcipher.CursorWindow.<init>(CursorWindow.java:72)
       at net.sqlcipher.database.SQLiteCursor.fillWindow(SQLiteCursor.java:301)
       at net.sqlcipher.database.SQLiteCursor.getCount(SQLiteCursor.java:292)
       at net.sqlcipher.AbstractCursor.moveToPosition(AbstractCursor.java:178)
       at net.sqlcipher.AbstractCursor.moveToFirst(AbstractCursor.java:222)
       at android.database.CursorWrapper.moveToFirst(CursorWrapper.java:65)
       ...
       ...

We have released a new version of our app by downgrading the SQLiteCipher version and the crashes have stopped.

What do you think could be happening, any idea how to solve it?

Thanks a lot for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions