Skip to content

chore: Support rusqlite 0.39.x - #425

Merged
jxs merged 2 commits into
rust-db:mainfrom
tomasol:pr-rusqlite-39
Apr 24, 2026
Merged

jxs merged 2 commits into
rust-db:mainfrom
tomasol:pr-rusqlite-39

Conversation

@tomasol

@tomasol tomasol commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

No description provided.

utof added a commit to utof/perima that referenced this pull request Apr 23, 2026
GH #131 documents an AB-BA lock-order inversion in SQLite's unixClose
vs unixLock-from-sqlite3WalClose code paths. Per upstream forum
https://sqlite.org/forum/info/a820be408ae265adb0de2b740633b179b2256420c1bb050fc9095566b18255b4
the bug was introduced in SQLite 3.51.0 (2025-11-04) by the new
unixIsSharingShmNode broken-POSIX-lock detection logic, which took
unixBigLock inside a scope already holding pInode->pLockMutex —
violating SQLite's own documented lock-order invariant. Reported
2025-12-05, patched same day, shipped in SQLite 3.51.2 (2026-01-09).
Release notes: https://sqlite.org/releaselog/3_51_2.html — "Fix an
obscure deadlock in the new broken-posix-lock detection logic."

rusqlite 0.38's bundled feature vendors SQLite 3.51.1 — the buggy
window. rusqlite 0.39 vendors SQLite 3.51.3 with the fix.

Workspace deps bumped:
- rusqlite       0.38 → 0.39
- r2d2_sqlite    0.32 → 0.33  (rusqlite 0.39 transitively requires
                                libsqlite3-sys 0.37; r2d2_sqlite 0.32
                                pinned 0.36 via rusqlite 0.38 →
                                links="sqlite3" conflict; 0.33 fixes)
- refinery       0.9.1 → 0.9  (relax requirement; PR branch is 0.9.0)
- libsqlite3-sys 0.36 → 0.37  (transitive via rusqlite 0.39)

[patch.crates-io] entry temporarily pins refinery + refinery-core to
the open PR rust-db/refinery#425 branch which
widens refinery's rusqlite cap from `<=0.38` to `<=0.39`. PR is
mergeable + all upstream CI green; awaiting maintainer merge. Patch
removal tracked in a separate follow-up issue (filed alongside this
commit).

Local verification (5 sequential `cargo nextest run -p perima-db`
runs, default parallelism, no retries):
  Pre-bump:  ~20% hang rate, 80s+ deadlocked test processes
  Post-bump: 5/5 PASS in ~8s each, 0 hangs.

Workarounds added in earlier commits on this branch (nextest retries=2
for perima-db, #[ignore] on 7 desktop _inner tests, slow-timeout
override for perima-desktop) are now logically dead code. They will be
reverted in a follow-up commit once CI confirms this fix.

@jxs jxs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jxs
jxs merged commit f4b23ea into rust-db:main Apr 24, 2026
29 checks passed
jxs added a commit that referenced this pull request Jun 10, 2026
* Prepare 0.9.2

- Bump versions to 0.9.2 in all crates
- Update inter-crate dependency references
- Add 0.9.2 changelog entries for TLS opt-in (#408),
  tokio-postgres-rustls feature (#426), rusqlite 0.39.x (#425),
  and toml 1.1.2 (#430)

* Bump mysql to 0.28.x and mysql_async to 0.37.x

* Apply suggestion from @jxs

* Apply suggestion from @jxs
CyberAshven added a commit to CyberAshven/OPTNWallet that referenced this pull request Nov 14, 2026
…0459)

RUSTSEC-2026-0459 (CVE-2026-119375: SQLite before 3.54.0 can return
uninitialised page-cache memory from a database opened with a -wal file
of another page size) reached dev through optn-chat's `sqlite` store.
mdk-sqlite-storage 0.8.0 requires rusqlite 0.37, whose libsqlite3-sys
0.35.0 bundles SQLCipher 4.6.1 on SQLite 3.46.1.

The advisory's patched range starts at libsqlite3-sys 0.39.0, which is
not enough for this store: its `bundled-sqlcipher` there is SQLCipher
4.19.0 on SQLite 3.53.4, still affected, as the advisory itself says.
The first SQLCipher on a fixed SQLite is 4.20.0 (SQLite 3.54.1):
sqlcipher-src 420.0.0, libsqlite3-sys 0.40.0, rusqlite 0.42.0.

No release gets there. mdk-sqlite-storage 0.8.0 is the latest on
crates.io, and MDK's main replaced the crate with another codebase that
sits on rusqlite 0.40.1 and a git pin of SQLCipher 4.17.0 (SQLite
3.53.3), so there is nothing to backport from it. refinery-core, which
runs the store's migrations, accepts rusqlite only up to 0.39 in 0.9.2
and 0.41 in 0.10.1 and on main.

Both crates are vendored and patched in their manifests only:

- mdk-sqlite-storage 0.8.0 takes rusqlite 0.42 with `cache` and
  `fallible_uint`, the two things rusqlite 0.38 made optional and this
  crate uses (prepare_cached; u64 columns and parameters). Its sources
  compile unchanged.
- refinery-core 0.9.2 accepts rusqlite up to 0.42, the one-line change
  upstream makes for each rusqlite release (rust-db/refinery#425, #445,
  #457). Its driver's calls are unchanged in 0.42.

optn-chat's own libsqlite3-sys requirement, which selects the vendored
OpenSSL build, moves from 0.35 to 0.40. Both lockfiles change only what
that needs: rusqlite, libsqlite3-sys and hashlink move, sqlcipher-src
(the SQLCipher source, now a crate of its own) comes in, with foldhash
0.2 in the root lock, and Cargo lists rusqlite's wasm-only
sqlite-wasm-rs and rsqlite-vfs.

How a store is keyed and laid out does not change: the same raw 32-byte
key and `cipher_compatibility = 4`, and SQLCipher 4.6.1 and 4.20.0 have
the same format defaults. A new optn-chat test opens a store written at
48e897c under SQLCipher 4.6.1, reads its group, members and messages,
writes to it, reopens it, and checks another identity's key is still
refused. It also fails if the linked SQLite is older than 3.54.0, which
a move back to libsqlite3-sys 0.39 would not show any scanner.

src-tauri's lockfile also carried advisories that entered the RustSec
database on 2026-11-11 and 2026-11-13, and two yanked releases. Each
moves by a precise update to the version the root lockfile already
resolves, and nothing else in that lock changes:

- quinn-proto 0.11.18 -> 0.11.19 (RUSTSEC-2026-0523, -0524);
- quinn-udp 0.5.15 -> 0.5.16 (RUSTSEC-2026-0538);
- rustix 1.1.5 -> 1.1.6 (RUSTSEC-2026-0486, unsound);
- async-executor 1.14.0 -> 1.14.1 and crypto-bigint 0.7.6 -> 0.7.10
  (yanked), the latter with ctutils 0.4.8.

CI audits the two replaced registry crates as it does the other vendored
ones. cargo audit reports no vulnerability for the root, src-tauri and
optn-core locks, and cargo deny's advisories pass for all three.
sqlcipher-src's licence expression needs the next commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants