Skip to content

[Android][Flutter release] Crash in DartWorker during PowerSyncDatabase.initialize() (SIGSEGV/SIGABRT, sometimes sqlite_async RangeError) #393

@sparrow58

Description

@sparrow58

Note: We are tracking this in powersync-ja/sqlite_async.dart#137.

Summary

We are seeing a release-only crash on Android when PowerSync initializes the local DB.
The crash happens in a DartWorker thread during PowerSyncDatabase.initialize() (or immediately around that call).

Debug mode works.
Release mode crashes consistently (startup or right after login, depending on startup sequencing).

Environment

  • Flutter: 3.41.4 (stable)
  • Dart: 3.11.1
  • Platform: Android 15 (arm64)
  • Device: Samsung SM-S908U
  • powersync: 1.18.0
  • powersync_core: 1.8.0
  • powersync_flutter_libs: 0.4.15+1
  • sqlite_async (transitive): 0.13.0
  • sqlite3: 2.9.4
  • sqlite3_flutter_libs: 0.5.41

Expected behavior

PowerSyncDatabase.initialize() should complete successfully in release mode (same as debug), and app should continue to sync normally.

Actual behavior

App crashes in release mode during DB initialization.

Crash signature A (native)

  • Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR)
  • thread: DartWorker
  • occurs right after app logs:
    • [DB_DIAG] before db.initialize()

Crash signature B (native VM abort)

  • Fatal signal 6 (SIGABRT)
  • Dart VM abort message includes:
    • runtime_entry.cc: ... hit null error with cid 94
  • thread: DartWorker

Crash signature C (Dart-side, seen in some variants)

  • RangeError (length): Invalid value: Valid value range is empty: 31
  • stack includes:
    • mapParameters (package:sqlite_async/src/utils/shared_utils.dart:78)
    • _sqliteConnectionIsolateInner.runStatement (...)

App-side call path (from logs)

AppDatabase._initDatabase -> AppDatabase.database -> AppDatabase.connectWithToken/watch... -> db.initialize()

Example trace from app logs:

  • [DB_DIAG] init start
  • [DB_DIAG] before creating PowerSyncDatabase
  • [DB_DIAG] before db.initialize()
  • then native crash in DartWorker

Repro notes

  • Reproducible in release builds.
  • Not reproducible in debug builds.
  • We also tested schema exclusion experiments:
    • Excluding item_categories and item_category_map changed behavior/signature in some runs, but crashes still occur in release.
  • Upgrading to latest powersync stack listed above did not resolve.

Additional context

This appears to be a release/AOT path issue in or around PowerSync/sqlite_async initialization on Android arm64.
Happy to run test builds or provide additional diagnostics if maintainers suggest specific instrumentation.

Artifacts available

I can provide:

  • full adb logcat -b crash output for both SIGSEGV and SIGABRT variants
  • full app logs around [DB_DIAG] before db.initialize()
  • minimal sanitized schema subset if needed

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