Skip to content

Share memory support#76

Merged
carlsverre merged 4 commits into
orbitinghail:mainfrom
bkoropoff:shm-mark3
Mar 1, 2026
Merged

Share memory support#76
carlsverre merged 4 commits into
orbitinghail:mainfrom
bkoropoff:shm-mark3

Conversation

@bkoropoff
Copy link
Copy Markdown
Contributor

This exposes an inherently unsafe interface, because sqlite demands it. 🤷‍♂️

The lifetime semantics of returned mapped regions are odd: the regions
are cached until all being released at once with `xShmUnmap`, but region
0 (the start of the file) might be fetched more than one.  This makes a
safe Rust interface nearly impossible, as sqlite wants to mutably alias
whatever you return to it.
@bkoropoff bkoropoff marked this pull request as ready for review February 24, 2026 07:14
@carlsverre carlsverre merged commit d9f9509 into orbitinghail:main Mar 1, 2026
1 check passed
@carlsverre
Copy link
Copy Markdown
Contributor

Thank you!

@carlsverre carlsverre mentioned this pull request Mar 1, 2026
russellromney added a commit to russellromney/sqlite-plugin that referenced this pull request Apr 13, 2026
iVersion was set to 3 in PR orbitinghail#76 when SHM support was added, but
xFetch and xUnfetch were left as None. SQLite interprets iVersion>=3
as "xFetch is callable" and does not null-check before calling.

Under concurrent WAL load (1 writer + 4 readers), SQLite's pager
calls xFetch during checkpoint page reads, jumping to address 0x0.
~60% SEGFAULT rate.

Fix: iVersion=2 (declares SHM support, not mmap support). SQLite
falls back to xRead for all page reads.

Includes regression test with a minimal file-backed VFS that
reproduces the crash without any external VFS implementation.
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