---
title: "How we used Quint to find over 10 bugs in SQLite while hardening Turso"
description: "Modeling individual SQLite C API contracts in Quint, generating small traces, and replaying them as C programs against real SQLite uncovered more than 10 SQLite bugs while also validating Turso's compatible C API."
url: "https://swe.quest/articles/how-we-used-quint-to-find-over-10-bugs-in-sqlite-while-hardening-turso-43686794db9fa980"
canonical: "https://turso.tech/blog/how-we-used-quint-to-find-over-10-bugs-in-sqlite"
source: "Turso"
published: "2026-05-18"
difficulty: "medium"
kind: "Case study"
reading_minutes: 5
tags: ["formal-methods","sqlite","testing","databases"]
---

# How we used Quint to find over 10 bugs in SQLite while hardening Turso

A post on [Turso](https://swe.quest/sources/turso.md), published 2026-05-18, 5 min read, Case study. Original: [https://turso.tech/blog/how-we-used-quint-to-find-over-10-bugs-in-sqlite](https://turso.tech/blog/how-we-used-quint-to-find-over-10-bugs-in-sqlite)

## Summary

Modeling individual SQLite C API contracts in Quint, generating small traces, and replaying them as C programs against real SQLite uncovered more than 10 SQLite bugs while also validating Turso's compatible C API. Rather than specifying the whole database, each documented contract was modeled with only the state it needs, so a divergence points either to a model error or to a real bug. One example: sqlite3\_deserialize() crashed instead of returning SQLITE\_BUSY during an active read transaction. Other findings include wrong results from EXISTS-to-join and UPDATE planning optimizations, xfer optimization bypassing type and CHECK constraints, and mutex alignment undefined behaviour.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Formal methods](https://swe.quest/tags/formal-methods.md) (Architecture & design)
- [SQLite](https://swe.quest/tags/sqlite.md) (Data & databases)
- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)
- [Databases](https://swe.quest/tags/databases.md) (Data & databases)

## Prerequisites

- SQLite C API ([easy posts on SQLite](https://swe.quest/tags/sqlite.md?difficulty=easy))
- formal methods basics ([easy posts on Formal methods](https://swe.quest/tags/formal-methods.md?difficulty=easy))
- model checking ([easy posts on Formal methods](https://swe.quest/tags/formal-methods.md?difficulty=easy))

## Keywords

Quint, SQLite, Turso, TLA+, sqlite3\_deserialize, Deterministic Simulation Testing

## Related posts

- [An adventure in writing compatible systems](https://swe.quest/articles/an-adventure-in-writing-compatible-systems-f48d37f87fc6e365.md): Turso · 2025-08-28 · Medium · 4 min read · SQLite, Storage engines, Formal methods, Debugging, Rust
  Turso, a Rust rewrite of SQLite, hit a bug where every write after the database crossed 1GB made SQLite's integrity checks fail, even though Turso's own checks found the file intact.
- [Introducing Limbo: A complete rewrite of SQLite in Rust](https://swe.quest/articles/introducing-limbo-a-complete-rewrite-of-sqlite-in-rust-eb77d828af295b26.md): Turso · 2024-12-10 · Easy · 7 min read · SQLite, Rust, Formal methods, Testing, WebAssembly
  Limbo is Turso's from-scratch rewrite of SQLite in Rust that aims for full language and file-format compatibility, memory safety and a modern architecture.
- [The final boss of reliability: formal verification](https://swe.quest/articles/the-final-boss-of-reliability-formal-verification-7d09556f91a9c3f0.md): Turso · 2026-07-07 · Medium · 6 min read · Formal methods, Testing, Storage engines, SQLite, Rust
  Turso, a from-scratch SQLite rewrite, is adding formal verification via Aretta AI's Aristo, which turns natural-language intents annotated on code into formally checked properties, to complement its deterministic simulation testing and Antithesis runs.
- [Carl Sverre ruined my day. And it was glorious](https://swe.quest/articles/carl-sverre-ruined-my-day-and-it-was-glorious-66c73969df61e4c5.md): Turso · 2026-04-23 · Easy · 5 min read · Testing, SQLite, JavaScript, AI for coding
  Turso used Antithesis's new property-based testing library Hegel to check that its two TypeScript drivers, the native @tursodatabase/database and the pure-JS @tursodatabase/serverless, expose the same API and return identical results.
- [Turso v0.7.0](https://swe.quest/articles/turso-v0-7-0-8d3ff93b34352c14.md): Turso · 2026-07-13 · Hard · 10 min read · SQLite, Storage engines, Consistency models, Memory management, Rust
  Turso 0.7 drops the beta label and focuses on performance and robustness for embedded, multi-tenant use: the core no longer blocks on I/O, yields CPU via a new StepResult::Yield, moves to fallible allocation so OOM surfaces as an error, and treats the page cache as a soft limit like SQLite.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
