Skip to content

Memory corruption issues on isolates #137

@orakemu

Description

@orakemu

Edit from team: These issues are likely the same underlying problem:

Summary

We reproduced a matched iOS profile-mode crash on a physical iPhone while using:

  • powersync 1.18.0
  • powersync_core 1.8.0
  • sqlite_async 0.13.1
  • sqlite3 2.9.4
  • iPhone 16 Pro, iOS 26.2 (23C55)

The crash is not in the native PowerSync/sqlite libs. It is caught by LLDB on a DartWorker thread inside App.framework, and symbolication points into the Dart-side sqlite connection-isolate path:

  • sqliteConnectionIsolateInner.handle
  • sqliteConnectionIsolateInner.runStatement
  • PortServer._init.<anonymous closure>
  • mapParameters

Repro shape

This was reproduced from a clean install on-device using:

  1. flutter build ios --profile --no-tree-shake-icons
  2. xcrun devicectl device install app ... build/ios/iphoneos/Runner.app
  3. LLDB waiting attach:
    • xcrun lldb -o "device select <CoreDevice id>" -o "device process attach -w -n Runner -c"
  4. Launch:
    • xcrun devicectl device process launch --device <CoreDevice id> <bundle-id>

Matched repro 1

Fresh matched crash:

  • Runner-2026-04-04-172738.ips
  • matching App.framework / dSYM UUID:
    • BF2DD795-731F-3166-95C8-F2A21751E099

LLDB caught:

  • EXC_BAD_ACCESS
  • SIGSEGV
  • faulting thread: DartWorker
  • faulting address: 0x83f69a47
  • App load address: 0x110ce8000

Top App frames:

frame #0: App`___lldb_unnamed_symbol_2e3c84 + 216
frame #1: App`___lldb_unnamed_symbol_2e3c84 + 192
frame #2: App`___lldb_unnamed_symbol_2e3ba4 + 88
frame #3: App`___lldb_unnamed_symbol_2e3a44 + 236
frame #4: App`___lldb_unnamed_symbol_2e3908 + 216
frame #5: App`___lldb_unnamed_symbol_2d2400 + 268
...
frame #18: Flutter`dart::DartEntry::InvokeFunction(...)
frame #19: Flutter`dart::IsolateMessageHandler::HandleMessage(...)

Symbolicated App frames:

profilerNameAndArgs (profiler.dart)
TimeSync.timeSync (profiler.dart)
sqliteConnectionIsolateInner.handle (native_sqlite_connection_impl.dart:374)
sqliteConnectionIsolateInner.<anonymous closure> (#2) (native_sqlite_connection_impl.dart:398)
PortServer._init.<anonymous closure> (port_channel_native.dart:252)
RawReceivePort._handleMessage (isolate_patch.dart:194)

Follow-up mitigations tested

We tested two more fresh profile builds:

  1. Force profileQueries: false for the PowerSync sqlite open factory.
  2. Force maxReaders: 1.

Both still crashed.

Matched repro 2: profileQueries: false

  • fresh crash: Runner-2026-04-04-174331.ips
  • matching UUID:
    • FE3FCBDA-A0D7-3785-99DB-EF86CC72A0B8

Still crashed on DartWorker with:

  • EXC_BAD_ACCESS
  • SIGSEGV
  • faulting address 0x74623

Symbolicated top frames:

FollowerLayer.findAnnotations (layer.dart:2688)
mapParameters (shared_utils.dart)
sqliteConnectionIsolateInner.runStatement
sqliteConnectionIsolateInner.handle.<anonymous closure>
TimeSync.timeSync
sqliteConnectionIsolateInner.handle
sqliteConnectionIsolateInner.<anonymous closure> (#2)
PortServer._init.<anonymous closure>

Matched repro 3: maxReaders: 1

  • fresh crash: Runner-2026-04-04-174733.ips
  • matching UUID:
    • D6659CCA-F367-38CC-963D-ACC59C81E244

Still crashed on DartWorker with:

  • EXC_BAD_ACCESS
  • SIGSEGV
  • faulting address 0x7

LLDB top frame:

frame #0: App`___lldb_unnamed_symbol_7db774 + 84

This means the crash is not explained by:

  • query timeline profiling alone
  • the default multi-reader pool width alone

Why I think this belongs here

The matched symbolication consistently lands in sqlite_async’s Dart-side isolate / port-channel / parameter-mapping codepath, not in app-specific feature code and not in the native sqlite / PowerSync extension binaries.

The strongest recurring frames are:

  • sqliteConnectionIsolateInner.runStatement
  • sqliteConnectionIsolateInner.handle
  • PortServer._init.<anonymous closure>
  • mapParameters

Question

Does this look like a known iOS profile-mode issue in the sqlite isolate path on sqlite_async 0.13.x?

If not, what would you recommend as the next best narrowing step?

  • instrument runStatement / mapParameters for the exact SQL + parameter types?
  • try an older sqlite_async line against the same app code?
  • avoid the isolate-backed connection implementation for PowerSync on iOS profile?

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