Repository navigation
sqlite: finalize statements prepared during close - #67539
Open
gengjiawen wants to merge 1 commit into
Open
gengjiawen wants to merge 1 commit into
gengjiawen wants to merge 1 commit into
Conversation
Collaborator
|
Review requested:
|
gengjiawen
force-pushed
the
sqlite-finalize-statements-during-close
branch
from
November 17, 2026 09:58
3fb7b48 to
2fe343a
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #67539 +/- ##
==========================================
+ Coverage 90.67% 90.71% +0.03%
==========================================
Files 800 801 +1
Lines 280489 280707 +218
Branches 54166 54177 +11
==========================================
+ Hits 254336 254638 +302
+ Misses 16277 16245 -32
+ Partials 9876 9824 -52
🚀 New features to boost your workflow:
|
cjihrig
approved these changes
Nov 17, 2026
Database::FinalizeStatements() range-iterates statements_ and then clears the set. Finalizing a statement with an open virtual-table cursor runs the generator's finally block, which can prepare a new statement and insert it into the set being iterated. That statement is never finalized, so it keeps running after close() releases the connection, and run() then dereferences a null connection. Erase each statement before finalizing it and continue until the set is empty, so statements created from that JavaScript are finalized before the connection is released. Assisted-by: Cursor Grok 4.7 Signed-off-by: gengjiawen <technicalcute@gmail.com>
gengjiawen
force-pushed
the
sqlite-finalize-statements-during-close
branch
from
November 18, 2026 03:50
2fe343a to
9c7aaf5
Compare
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Database::FinalizeStatements()range-iteratedstatements_and then cleared the set. Finalizing a statement with an open virtual-table cursor runs the generator'sfinallyblock, and that JavaScript canprepare()another statement. The new statement was inserted into the set being iterated, so it was never finalized.sqlite3_close_v2()then left the connection open, andStatement::Run()dereferenced a null connection.The same path runs from
Database::Deserialize().Erase each statement before finalizing it and keep going until the set is empty, so a statement created from that
finallyblock is finalized before the connection is released. AnINSERTdone fromfinallystill commits, because it runs while the connection is open.Test plan
node --expose-gc --test test/parallel/test-sqlite-virtual-table.jsINSERTfromfinallyis visible after reopen, and that the statement prepared there throwsstatement has been finalized.finallyon top of a statement that was already open.deserialize()finalizes a statement prepared while the previous database is dropped, then a new query reads the replacement database.Made with Cursor