New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destroying a database object quickly after creating it is unsafe #518

ajbeamon opened this Issue Jun 21, 2018 · 1 comment


None yet
2 participants
Copy link

ajbeamon commented Jun 21, 2018

Consider the following sequence of operations in the C API:

  1. A database DB is created with fdb_cluster_create_database.
  2. A transaction is created with fdb_database_create_transaction using DB
  3. DB is destroyed with fdb_database_destroy.

There is a race condition in the above such that the DatabaseContext used by the transaction may get deleted prior to it being used by the transaction, in which case we get invalid memory accesses.

The specific problem seems to be a question of who does the final delref on DB. If it happens in step 3, then we should be fine (so long as step 3 isn't happening on the network thread). If it happens in step 1 (which is on the network thread), then the DatabaseContext can be destroyed prematurely.

See for more discussion of this.

@ajbeamon ajbeamon changed the title Deleting a database quickly after creating it is unsafe Destroying a database object quickly after creating it is unsafe Jun 21, 2018

@hgray1 hgray1 added this to the 6.0 milestone Jun 25, 2018

@hgray1 hgray1 modified the milestones: 6.0, 6.1 Jul 2, 2018

@ajbeamon ajbeamon modified the milestones: 6.1, 6.0 Jul 17, 2018


This comment has been minimized.

Copy link

ajbeamon commented Jul 17, 2018

Addressed by #610, which empties the queue of tasks scheduled from other threads before adding tasks from the network thread when calling onMainThread.

@ajbeamon ajbeamon closed this Jul 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment