Skip to content

Infinite recursion when _databaseFactory is null in SentrySqfliteDatabaseFactory (line 53) #3229

@KevinTheMix

Description

@KevinTheMix

Platform

Dart, Flutter Mobile Android

Obfuscation

Disabled

Debug Info

Disabled

Doctor

N/A (not an environment problem)

Version

9.6.0

Steps to Reproduce

  1. Following the official tutorial, I set up sqflite databaseFactory like this: databaseFactory = SentrySqfliteDatabaseFactory(); (without passing an argument to its inner databaseFactory property, which does prevent the issue as a workaround)
  2. When I then run either openDatabase() or openDatabaseWithSentry(), the openDatabase method in SentrySqfliteDatabaseFactory is called (in file sentry_sqflite_database_factory.dart)
  3. At line 53, this code happens: final databaseFactory = _databaseFactory ?? this; and since _databaseFactory is null, that local databaseFactory instance receives this
  4. That causes unintended recursion at line 57, since the method now calls itself

Expected Result

If _databaseFactory is null (when SentrySqfliteDatabaseFactory's databaseFactory isn't set) , openDatabase() should fallback to the global default sqflite databaseFactory, not itself. There should be no risk of recursion or stack overflow.

Actual Result

When tracing is disabled and _databaseFactory is null, calling openDatabase may result in infinite recursion or a stack overflow, as the factory calls itself repeatedly.

Are you willing to submit a PR?

Yes

Metadata

Metadata

Assignees

Labels

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions