You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Windows release UAT: the sqlite3 scenario's contract is refused, a proof says sqlite3_prepare_v2 stores param 0 (Windows only) #3374
Found by the dispatched nightly release, run 43869111995 (2026-11-16), job "Verify and package windows-x86_64", step Release UAT, scenario sqlite3 (step 7, with run). The same scenario passes on darwin-aarch64 and linux-x86_64 in the same run.
error: `fn sqlite3_prepare_v2` lends param 0, which contradicts a proof: the function stores param 0
= proof: passed to sqlite3LockAndPrepare at param 0, passed to sqlite3Prepare at param 0, stored in a field
--> out/uat/sqlite3/tmp/src/contracts/sqlite3.w:102:5
error: `fn sqlite3_exec` lends param 0, which contradicts a proof: the function stores param 0
= proof: passed to sqlite3_prepare_v2 at param 0, passed to sqlite3LockAndPrepare at param 0, passed to sqlite3Prepare at param 0, stored in a field
--> out/uat/sqlite3/tmp/src/contracts/sqlite3.w:150:5
The scenario is a contract program: it is not edited. Either the proof engine reads a store on Windows that is not one (a compiler bug, as the message says), or the Windows build of sqlite3 that with get provides really keeps the sqlite3 * in a field on a path the other platforms do not compile, and then lend is wrong there and the answer is Eric (C interop).
Not yet done: which field store in sqlite3Prepare the proof found on Windows, and why it is not found elsewhere (with analyze … contract on the Windows build names it). Captures: artifact uat-captures-build-windows-0, uat/sqlite3/step-7.stderr.
Not Windows-specific. sqlite3 is built from source on Windows, so contract-proofs.txt binds there; on darwin and Linux it is a prebuilt Conan binary and the same evidence "grants nothing". The Mac's contract-evidence.txt carries the same line.
The stores proof is wrong twice over:
A record in the function's own frame.sqlite3Prepare has Parse sParse; … sParse.db = db;. CImport.ci_body_call_evidence_walk wrote field:<param> for any member store, and ci_own_walk a paramstore. Fixed on branch frame-field-store (commit 4c201ed, battery running): such a store is frame: evidence, which a drawn contract still treats as retained and which is no proof; a record the body copies out, returns or declares static is still a store. Test: test/internals/conan_contract_proofs_frame_record_test.w (9 cases; failed before).
A back-pointer in memory the parameter itself owns. With (1) fixed the proof finds the next store:
sqlite3_prepare_v2 → sqlite3LockAndPrepare → sqlite3Prepare → sqlite3ErrorWithMsg → sqlite3ValueNew, stored in a field
sqlite3ErrorWithMsg does db->pErr = sqlite3ValueNew(db), and sqlite3ValueNew does p->db = db on the value it allocates. The store is real, but its only holder is db itself: nothing outside db keeps db past the call. Behind it sits a third of the same family: the Vdbe keeps db and is the product (*ppStmt), which the contract already states (Statement … borrows param 0); sqlite3_exec makes that product and finalizes it before returning.
The question (C interop; Eric's)
The engine's stores is a may-store fact (some field somewhere receives the pointer) used as a must fact (the function keeps the parameter past the call).
What the others do. Rust's borrow checker and Swift's ownership work on declared signatures, never on C bodies; Zig's translate-c and Go's cgo prove nothing about C. Clang's static analyzer and -Wdangling treat a store as an escape only when the destination outlives the frame and is not the object itself. None has a stated-grant-versus-proof check; this is With's own.
What the spec says. §31.7: "A proof contradicts a grant when it establishes a fact the grant denies"; "A proof is weaker than a grant when it fails to establish what the grant says and establishes nothing against it"; "Every override is a possible compiler bug … a proof believed wrong is a compiler bug". Its own example of a wrong proof is a store "into the caller's own scratch slot", answered with override lend. §31.5: lend: "the function keeps and frees nothing of its resource parameters"; borrows param p: "the product depends on the resource received at p and cannot outlive it".
Options.
A. The engine claims stores only for a store that escapes. Not an escape: a record in the frame (done); memory reachable only from the parameter itself (db->pErr); a product the contract says borrows that parameter, or one the same body destroys. Everything else it cannot follow becomes weaker, not a contradiction. Drawn contracts stay as conservative as today. This is engine work in several steps.
B. The scenario's contract writes override lend on sqlite3_prepare_v2 and sqlite3_exec, each with its citation. It is the spec's stated answer to a wrong proof and is stale (accepted) on the platforms with a prebuilt binary. It edits a contract program, and puts override on the two most used functions of the flagship facade.
Mission fit. A: the programmer never writes what the compiler could have known; an override forced by a back-pointer is ceremony with no guardrail. B is the smallest change and keeps every refusal, at the price of teaching that override is routine.
Prediction. A, 75%: "every override is a possible compiler bug" and "we own every bug". B only as a stopgap you would have to name yourself.
Until ruled, the Windows sqlite3 scenario stays red in the nightly release.
Update: what option A costs for sqlite3 (measured, 2026-11-16)
Part 1 is merged (#3381): a store into a record of the function's own frame is no proof. With it, WITH_DEBUG_MIGRATE_FACADE=1 with get c.sqlite3 shows what still makes sqlite3_prepare_v2 and sqlite3_exec "store" db. sqlite3Prepare has one retaining callee left, sqlite3ErrorWithMsg, and that one has two chains:
db->pErr = sqlite3ValueNew(db), where sqlite3ValueNew does p->db = db on p = sqlite3DbMallocZero(db, …) and returns p.
sqlite3VMPrintf(db, …) → sqlite3StrAccumInit(&acc, db, …), which does p->db = db through its first parameter; the caller passed the address of a frame record.
Chain 2 is provable with a per-call summary ("the callee stores param 1 into what param 0 points at; this caller passes &acc, a frame record"). Chain 1 is not, short of modeling sqlite's allocator: p must be shown to be reachable only through db, and sqlite3DbMallocZero returns either a slot of db's own lookaside buffer or memory from sqlite3GlobalConfig.m.xMalloc, a function-pointer field. Without that, "stored into memory of unknown provenance, then put in db->pErr" cannot be told from a store into a shared object.
So A does not turn this scenario green with one more step. It needs: holder summaries across calls (started locally, branch holder-proofs, evidence only, not pushed), then allocator provenance through a function-pointer configuration and a per-handle pool. That is the work #3124 and #3175 already describe; it is a campaign.
Revised prediction: B now, A continues under #3124/#3175 (60%). The spec's own example of a wrong proof is this case ("the store is into the caller's own scratch slot" → override lend with a citation), the override is stale-and-accepted on the platforms that link a prebuilt sqlite3, and each override is deleted when the proof learns the case (the contract audit reports it stale). The text B would add to uat/sqlite3.uat, for your blessing or edit:
fn sqlite3_prepare_v2
override lend // sqlite3.c, sqlite3ValueNew: `p->db = db` is the back-pointer of db's own error value (db->pErr), freed by sqlite3_close
fn sqlite3_exec
override lend // the same store, reached through sqlite3_prepare_v2; the statement it prepares is finalized before sqlite3_exec returns
(placed with the clauses those two fn items already carry). Nothing in the scenario is changed until you say so.
Option B ruled by Eric (2026-11-16) and merged in #3392: override lend on sqlite3_prepare_v2 and sqlite3_exec, his blessed text. Verified on the Mac with the Windows proofs placed beside the fetched package: without the overrides, this issue's two errors; with them, the check is ok and audit:contract reports overrides=2. The nightly is dispatched on main cf31b08 (run 44020768813) to confirm the Windows scenario; this closes when it is green there. Option A continues under #3124 / #3175, and each override goes when the audit reports it stale on Windows.
Confirmed on Windows: nightly run 44110846423 (main d3bfa28), job "Verify and package windows-x86_64": :test and Release UAT both succeeded, the first run to reach the sqlite3 scenario with the override lend clauses of #3392.
Activity
ehartford commentedon Nov 16, 2026
Root cause (2026-11-16)
Not Windows-specific. sqlite3 is built from source on Windows, so
contract-proofs.txtbinds there; on darwin and Linux it is a prebuilt Conan binary and the same evidence "grants nothing". The Mac'scontract-evidence.txtcarries the same line.The
storesproof is wrong twice over:A record in the function's own frame.
sqlite3PreparehasParse sParse; … sParse.db = db;.CImport.ci_body_call_evidence_walkwrotefield:<param>for any member store, andci_own_walkaparamstore. Fixed on branchframe-field-store(commit 4c201ed, battery running): such a store isframe:evidence, which a drawn contract still treats as retained and which is no proof; a record the body copies out, returns or declaresstaticis still a store. Test:test/internals/conan_contract_proofs_frame_record_test.w(9 cases; failed before).A back-pointer in memory the parameter itself owns. With (1) fixed the proof finds the next store:
sqlite3ErrorWithMsgdoesdb->pErr = sqlite3ValueNew(db), andsqlite3ValueNewdoesp->db = dbon the value it allocates. The store is real, but its only holder isdbitself: nothing outsidedbkeepsdbpast the call. Behind it sits a third of the same family: theVdbekeepsdband is the product (*ppStmt), which the contract already states (Statement … borrows param 0);sqlite3_execmakes that product and finalizes it before returning.The question (C interop; Eric's)
The engine's
storesis a may-store fact (some field somewhere receives the pointer) used as a must fact (the function keeps the parameter past the call).What the others do. Rust's borrow checker and Swift's ownership work on declared signatures, never on C bodies; Zig's translate-c and Go's cgo prove nothing about C. Clang's static analyzer and
-Wdanglingtreat a store as an escape only when the destination outlives the frame and is not the object itself. None has a stated-grant-versus-proof check; this is With's own.What the spec says. §31.7: "A proof contradicts a grant when it establishes a fact the grant denies"; "A proof is weaker than a grant when it fails to establish what the grant says and establishes nothing against it"; "Every override is a possible compiler bug … a proof believed wrong is a compiler bug". Its own example of a wrong proof is a store "into the caller's own scratch slot", answered with
override lend. §31.5:lend: "the function keeps and frees nothing of its resource parameters";borrows param p: "the product depends on the resource received atpand cannot outlive it".Options.
storesonly for a store that escapes. Not an escape: a record in the frame (done); memory reachable only from the parameter itself (db->pErr); a product the contract saysborrowsthat parameter, or one the same body destroys. Everything else it cannot follow becomes weaker, not a contradiction. Drawn contracts stay as conservative as today. This is engine work in several steps.override lendonsqlite3_prepare_v2andsqlite3_exec, each with its citation. It is the spec's stated answer to a wrong proof and is stale (accepted) on the platforms with a prebuilt binary. It edits a contract program, and putsoverrideon the two most used functions of the flagship facade.Mission fit. A: the programmer never writes what the compiler could have known; an
overrideforced by a back-pointer is ceremony with no guardrail. B is the smallest change and keeps every refusal, at the price of teaching thatoverrideis routine.Prediction. A, 75%: "every override is a possible compiler bug" and "we own every bug". B only as a stopgap you would have to name yourself.
Until ruled, the Windows sqlite3 scenario stays red in the nightly release.
with get: a parameter stored into a field of a record in the function…
ehartford commentedon Nov 16, 2026
Update: what option A costs for sqlite3 (measured, 2026-11-16)
Part 1 is merged (#3381): a store into a record of the function's own frame is no proof. With it,
WITH_DEBUG_MIGRATE_FACADE=1 with get c.sqlite3shows what still makessqlite3_prepare_v2andsqlite3_exec"store"db.sqlite3Preparehas one retaining callee left,sqlite3ErrorWithMsg, and that one has two chains:db->pErr = sqlite3ValueNew(db), wheresqlite3ValueNewdoesp->db = dbonp = sqlite3DbMallocZero(db, …)and returnsp.sqlite3VMPrintf(db, …)→sqlite3StrAccumInit(&acc, db, …), which doesp->db = dbthrough its first parameter; the caller passed the address of a frame record.Chain 2 is provable with a per-call summary ("the callee stores param 1 into what param 0 points at; this caller passes
&acc, a frame record"). Chain 1 is not, short of modeling sqlite's allocator:pmust be shown to be reachable only throughdb, andsqlite3DbMallocZeroreturns either a slot ofdb's own lookaside buffer or memory fromsqlite3GlobalConfig.m.xMalloc, a function-pointer field. Without that, "stored into memory of unknown provenance, then put indb->pErr" cannot be told from a store into a shared object.So A does not turn this scenario green with one more step. It needs: holder summaries across calls (started locally, branch
holder-proofs, evidence only, not pushed), then allocator provenance through a function-pointer configuration and a per-handle pool. That is the work #3124 and #3175 already describe; it is a campaign.Revised prediction: B now, A continues under #3124/#3175 (60%). The spec's own example of a wrong proof is this case ("the store is into the caller's own scratch slot" →
override lendwith a citation), the override is stale-and-accepted on the platforms that link a prebuilt sqlite3, and each override is deleted when the proof learns the case (the contract audit reports it stale). The text B would add touat/sqlite3.uat, for your blessing or edit:(placed with the clauses those two
fnitems already carry). Nothing in the scenario is changed until you say so.uat/sqlite3: override lend on sqlite3_prepare_v2 and sqlite3_exec (Er…
ehartford commentedon Nov 17, 2026
Option B ruled by Eric (2026-11-16) and merged in #3392:
override lendonsqlite3_prepare_v2andsqlite3_exec, his blessed text. Verified on the Mac with the Windows proofs placed beside the fetched package: without the overrides, this issue's two errors; with them, the check is ok andaudit:contractreportsoverrides=2. The nightly is dispatched on main cf31b08 (run 44020768813) to confirm the Windows scenario; this closes when it is green there. Option A continues under #3124 / #3175, and each override goes when the audit reports it stale on Windows.ehartford commentedon Nov 17, 2026
Confirmed on Windows: nightly run 44110846423 (main d3bfa28), job "Verify and package windows-x86_64":
:testandRelease UATboth succeeded, the first run to reach the sqlite3 scenario with theoverride lendclauses of #3392.