sqlite: prevent reentrant statement finalization - #64796
Open
trivikr wants to merge 1 commit into
Open
Conversation
Track statement execution depth while calling sqlite3_step(). Reject close() and deserialize() while a statement is executing so callbacks cannot finalize the active statement and crash. Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: codex:gpt-5.6-sol
Collaborator
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #64796 +/- ##
==========================================
- Coverage 90.16% 90.13% -0.04%
==========================================
Files 744 744
Lines 242518 242524 +6
Branches 45705 45693 -12
==========================================
- Hits 218670 218601 -69
- Misses 15357 15422 +65
- Partials 8491 8501 +10
🚀 New features to boost your workflow:
|
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.
Fixes: #64795
A scalar or aggregate callback can call
db.close()while its preparedstatement is executing inside
sqlite3_step().close()then finalizes thecurrently executing statement, and execution resumes with an invalid statement,
causing the process to crash.
db.deserialize()has the same issue because italso finalizes existing statements.
This change tracks statement execution depth around
sqlite3_step()andrejects
close()anddeserialize()withERR_INVALID_STATEwhile a statementis executing.
Assisted-by: codex:gpt-5.6-sol