Skip to content

Out of memory on MacOS #115

@mitrakov

Description

@mitrakov

Bug

  1. When I try to open an encrypted file on MacOS with an invalid password, it shows:
2026-01-10 20:03:50.848 Las Notes[13125:2254487] DB Error: 26 "file is not a database"
2026-01-10 20:03:50.848 Las Notes[13125:2254487] DB Query: SELECT COUNT(*) FROM sqlite_schema
2026-01-10 20:03:50.848 Las Notes[13125:2254487] DB Path: /Volumes/Macintosh HD/Users/director/Yandex.Disk.localized/db/a.dbx
2026-01-10 20:03:50.851 Las Notes[13125:2254487] Error: Message responses can be sent only once. Ignoring duplicate response on channel 'com.davidmartos96.sqflite_sqlcipher'.

which is totally fine.

  1. But then, when I provide a valid password, it suddenly shows:
2026-01-10 20:04:10.988 Las Notes[13125:2254493] Unknown error calling sqlite3_step (7: out of memory) rs
2026-01-10 20:04:10.991 Las Notes[13125:2254493] Unknown error calling sqlite3_step (7: out of memory) rs
flutter: error DatabaseException(Error Domain=FMDatabase Code=7 "out of memory" UserInfo={NSLocalizedDescription=out of memory}) sql 'BEGIN EXCLUSIVE' args [] during open, closing...
2026-01-10 20:04:10.994 Las Notes[13125:2254493] Error calling sqlite3_step (1: cannot rollback - no transaction is active) rs

which is quite strange (it should not be an error at all).

  1. Next and all subsequent calls with a valid password work fine, without errors.

Workaround

For workaround, I just call "openDatabase" twice:

try {
  await _db.openDatabase(path, password: password, ...);
} catch (e) {
  if (e.toString().contains("file is not a database") || e.toString().startsWith("DatabaseException(open_failed")) {
    // it's OK, just show a error to a User
  } else if (e.toString().startsWith('DatabaseException(Error Domain=FMDatabase Code=7 "out of memory"')) {
    openFile(context, path, password: password); // Bug in sqflite_sqlcipher: let's make a recursive call
  } else ...;
}

Info

  • sqflite_sqlcipher: 3.4.0
  • MacOS Tahoe 26.2, Apple M1
  • xCode 26.2
  • Flutter 3.38.5
  • Dart 3.10.4
  • CocoaPods 1.16.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions