esqlite: Race condition: Occasional VM crash due to dangling pointer to sqlite3_stmt struct

As mentioned in my final comment on #33, I am still seeing occasional VM crashes, though with new symptoms. The crashes I am seeing now are always segfaults (no assertion failures as in #33), and with a build instrumented to print stack traces, the crashes are always in sqlite3_* API functions.

I believe the following sequence of operations is happening:

  1. (scheduler thread) Create DB.
  2. (scheduler thread) Prepare a statement.
  3. (scheduler thread) Request information about that prepared statement (i.e. column_names). Queues request to command processing thread.
  4. (scheduler thread) Thread gets killed.
  5. (scheduler thread) Garbage collects statement reference, thus triggering a call to sqlite3_finalize.
  6. (command processing thread) Processes the request queued at step 3, thus triggering a call to sqlite3_column_name using a now-defunct pointer to sqlite3_stmt. crash

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (18 by maintainers)

Most upvoted comments

Thank you too. And Ecto2’s test routines.

This is probably the first stable release of esqlite.