sqlite: reject deserialize() while in a callback - #64796
Conversation
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #64796 +/- ##
==========================================
+ Coverage 90.29% 90.31% +0.02%
==========================================
Files 759 759
Lines 248295 248296 +1
Branches 46861 46857 -4
==========================================
+ Hits 224205 224258 +53
+ Misses 15517 15465 -52
Partials 8573 8573
🚀 New features to boost your workflow:
|
c11abfd to
4af37c6
Compare
4af37c6 to
c64b289
Compare
46139cd to
e6c5c8c
Compare
TrevorBurnham
left a comment
There was a problem hiding this comment.
The guard itself looks right to me: IsInCallback() is the correct predicate, since the crash needs a live sqlite3_step() frame, which is only reachable from a callback, and every step-reentrant entry point (xFunc, xStepBase/xValueBase, the authorizer, sqlite3changeset_apply) already takes CallbackDepthGuard. Placing it before FinalizeStatements() also means a rejected call leaves no partial state. Three non-blocking notes below, plus one on the docs.
doc/api/sqlite.md: the new throwing condition isn't documented. The database.deserialize() section only mentions that existing statements are finalized first; it'd help to state that the method throws ERR_INVALID_STATE when called from a user-defined function, aggregate, authorizer, or changeset filter/conflict callback. The same is missing for database.close() from #64743 — might be worth adding both here.
e6c5c8c to
19c3939
Compare
deserialize() could be called from a user-defined function invoked during statement execution, tearing down the database connection while sqlite3_step() was still using it. Reuse the existing callback depth check to throw ERR_INVALID_STATE instead, matching the guard already in place for close(). Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: codex:gpt-5.6-sol
0f44d09 to
ae8a08a
Compare
ae8a08a to
0081aa8
Compare
Fixes: #64795
deserialize() could be called from a user-defined function invoked during statement execution, tearing down the database connection while sqlite3_step() was still using it. Reuse the existing callback depth check to throw ERR_INVALID_STATE instead, matching the guard already in place for close().
Assisted-by: codex:gpt-5.6-sol