Repository navigation
sqlite: guard re-entrant reset of a virtual table cursor - #67540
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-guard-reentrant-statement-reset
branch
from
November 17, 2026 09:58
6bc0ffe to
fc48f73
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #67540 +/- ##
=======================================
Coverage 90.71% 90.71%
=======================================
Files 801 801
Lines 280705 280716 +11
Branches 54168 54174 +6
=======================================
+ Hits 254640 254660 +20
+ Misses 16247 16241 -6
+ Partials 9818 9815 -3
🚀 New features to boost your workflow:
|
This comment was marked as resolved.
This comment was marked as resolved.
StatementIterator::Return() and SQLTagStore::ResetAndBindStatement() called sqlite3_reset() without a SteppingStatementGuard. Resetting a statement with an open virtual-table cursor runs the generator's finally block, and that JavaScript can reset the same statement again. SQLite then halts the VM a second time while the cursor slot still points at the cursor, so xClose frees the same NodeVTabCursor twice. Hold the stepping guard across those resets so the re-entrant call fails with "statement is already being executed" instead of closing the cursor again. Ignore a second xClose on a cursor that is already closing. Assisted-by: Cursor Grok 4.7 Signed-off-by: gengjiawen <technicalcute@gmail.com>
gengjiawen
force-pushed
the
sqlite-guard-reentrant-statement-reset
branch
from
November 18, 2026 03:50
fc48f73 to
600ae5d
Compare
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
StatementIterator::Return()andSQLTagStore::ResetAndBindStatement()calledsqlite3_reset()without aSteppingStatementGuard. Resetting a statement that has an open virtual-table cursor runs the generator'sfinallyblock. JavaScript there can reset the same statement again. SQLite then halts the VM a second time while the cursor slot still points at the cursor, soxClosefrees the sameNodeVTabCursortwice.Hold the stepping guard across those resets. The re-entrant call fails with
statement is already being executedinstead of closing the cursor again.SQLTagStore::All()holds the same guard so its trailing reset is covered too. A cursor that is already closing ignores a secondxClose.Test plan
node --expose-gc --test test/parallel/test-sqlite-virtual-table.jsnode --expose-gc --test test/parallel/test-sqlite-udf-close.jsfinallycallsiterator.return(),statement.get(), and the same taggedget()while the outer reset is in progress. Each re-entry throwsERR_INVALID_STATE.for...ofwithbreakcovers the same path throughStatementIterator::Return().Made with Cursor