GeezerVison is showing github.com — sqlite: copy changeset before applying it by mcollina · Pull Request #65286 · nodejs/node
Conversation
SQLite can invoke JavaScript conflict and filter callbacks while applying a changeset. Copy the input first so detaching or modifying its backing buffer during a callback does not affect the active operation.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
codecov
Bot
commented
Aug 14, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
❌ Patch coverage is 58.82353% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.12%. Comparing base (cc57cb7) to head (994c5d3).
⚠️ Report is 155 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #65286 +/- ##
==========================================
- Coverage 90.12% 90.12% -0.01%
==========================================
Files 751 751
Lines 252536 252558 +22
Branches 47519 47518 -1
==========================================
+ Hits 227598 227612 +14
Misses 16250 16250
- Partials 8688 8696 +8
... and 33 files with indirect coverage changes
🚀 New features to boost your workflow:
- ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
SQLite can invoke JavaScript conflict and filter callbacks while
applying a changeset. Copy the input first so detaching or modifying
its backing buffer during a callback does not affect the active
operation.
Signed-off-by: Matteo Collina <[email protected]>
Refactor: only copy the changeset before applying it when a filter or
onConflict callback is present, since SQLite can only invoke JavaScript
mid-apply in that case. Without callbacks, the input buffer cannot be
detached or modified during sqlite3changeset_apply(), so no copy is
needed and the buffer is passed through directly.
Address review comment from geeksilva97.
Signed-off-by: Matteo Collina <[email protected]>
trivikr
added
request-ci
Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review.
author ready
PRs with CI started, the required approvals, and no outstanding review comments.
labels
Aug 31, 2026
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Commit Queue failed
This pull request has multiple commits, but no landing policy was selected.
Add
commit-queue-squash
PRs the Commit Queue should land as one squashed commit.
to land it as one commit, or
commit-queue-rebase
PRs the Commit Queue should land as multiple self-contained commits.
to land the commits separately.
The pull request was removed from the Commit Queue and labeled
commit-queue-failed
PRs whose Commit Queue landing failed and need manual intervention before retrying.
. After resolving the failure, remove that label and add
commit-queue
PRs queued for automated landing through the Commit Queue.
to retry.
Full Commit Queue output
- Loading data for nodejs/node/pull/65286
✔ Done loading data for nodejs/node/pull/65286
----------------------------------- PR info ------------------------------------
Title sqlite: copy changeset before applying it (#65286)
Author Matteo Collina <[email protected]> (@mcollina)
Branch mcollina:fix-sqlite-apply-changeset-buffer -> nodejs:main
Labels c++, author ready, needs-ci, commit-queue, sqlite
Commits 2
- sqlite: copy changeset before applying it
- sqlite: skip copying changeset when no callbacks are set
Committers 1
- Matteo Collina <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/65286
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/65286
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
--------------------------------------------------------------------------------
ℹ This PR was created on Fri, 14 Aug 2026 14:41:01 GMT
✔ Approvals: 3
✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/65286#pullrequestreview-4978555574
✔ - Edy Silva (@geeksilva97): https://github.com/nodejs/node/pull/65286#pullrequestreview-4985966385
✔ - Trivikram Kamat (@trivikr): https://github.com/nodejs/node/pull/65286#pullrequestreview-5063773955
✔ Last GitHub CI successful
ℹ Last Full PR CI on 2026-08-31T07:00:27Z: https://ci.nodejs.org/job/node-test-pull-request/76751/
- Querying data for job/node-test-pull-request/76751/
✔ Build data downloaded
✔ Last Jenkins CI successful
--------------------------------------------------------------------------------
✔ No git cherry-pick in progress
✔ No git am in progress
✔ No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
* branch main -> FETCH_HEAD
✔ origin/main is now up-to-date
- Downloading patch for 65286
From https://github.com/nodejs/node
* branch refs/pull/65286/merge -> FETCH_HEAD
✔ Fetched commits as f2c515510d1f..994c5d3853e4
--------------------------------------------------------------------------------
Auto-merging src/node_sqlite.cc
Auto-merging test/parallel/test-sqlite-session.js
[main 8ce2a31f3a] sqlite: copy changeset before applying it
Author: Matteo Collina <[email protected]>
Date: Fri Aug 14 16:31:01 2026 +0200
2 files changed, 70 insertions(+), 2 deletions(-)
Auto-merging src/node_sqlite.cc
[main ca76c773fc] sqlite: skip copying changeset when no callbacks are set
Author: Matteo Collina <[email protected]>
Date: Wed Aug 19 17:10:00 2026 +0000
1 file changed, 9 insertions(+), 7 deletions(-)
✔ Patches applied
There are 2 commits in the PR. Attempting autorebase.
(node:436) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Rebasing (2/4)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
sqlite: copy changeset before applying it
SQLite can invoke JavaScript conflict and filter callbacks while
applying a changeset. Copy the input first so detaching or modifying
its backing buffer during a callback does not affect the active
operation.
Signed-off-by: Matteo Collina <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/65286
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
--------------------------------------------------------------------------------
[detached HEAD 2b06c78482] sqlite: copy changeset before applying it
Author: Matteo Collina <[email protected]>
Date: Fri Aug 14 16:31:01 2026 +0200
2 files changed, 70 insertions(+), 2 deletions(-)
Rebasing (3/4)
Rebasing (4/4)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
sqlite: skip copying changeset when no callbacks are set
Refactor: only copy the changeset before applying it when a filter or
onConflict callback is present, since SQLite can only invoke JavaScript
mid-apply in that case. Without callbacks, the input buffer cannot be
detached or modified during sqlite3changeset_apply(), so no copy is
needed and the buffer is passed through directly.
Address review comment from geeksilva97.
Signed-off-by: Matteo Collina <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/65286
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
--------------------------------------------------------------------------------
[detached HEAD 3bb617deec] sqlite: skip copying changeset when no callbacks are set
Author: Matteo Collina <[email protected]>
Date: Wed Aug 19 17:10:00 2026 +0000
1 file changed, 9 insertions(+), 7 deletions(-)
Successfully rebased and updated refs/heads/main.
--------------------------------------------------------------------------------
ℹ Add `commit-queue-squash` label to land the PR as one commit, or `commit-queue-rebase` to land as separate commits.
View workflow run
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
aduh95
pushed a commit
that referenced
this pull request
Sep 3, 2026
SQLite can invoke JavaScript conflict and filter callbacks while
applying a changeset. Copy the input first so detaching or modifying
its backing buffer during a callback does not affect the active
operation.
Signed-off-by: Matteo Collina <[email protected]>
PR-URL: #65286
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
mceachen
added a commit
to photostructure/node-sqlite
that referenced
this pull request
Sep 8, 2026
…aging
Sync node_sqlite.cc and the compatibility tests from nodejs/node
v26.x-staging@b4f5d35 and port the four fixes it carries:
- re-validate that the database is still open after reading an options
bag, and validate callback `length` as int32 (nodejs/node#65595): a
getter can close the database mid-call; applyChangeset() segfaulted
and createSession() returned a session on a closed connection
- reject deserialize() when a getter shrank or detached the buffer
(nodejs/node#65595): the stale byte_length read past the backing store
- copy the changeset before sqlite3changeset_apply() when callbacks are
set (nodejs/node#65286): a callback can detach or overwrite the input
- reject session.close() and dispose from any SQLite callback
(nodejs/node#65454): the session module reaches into JavaScript from
its pre-update hook while still walking the session list, so deleting
a session there is a use-after-free
nodejs/node#65666 (backup completion in a callback scope) needs no port:
node-addon-api's AsyncWorker already completes inside one, and the new
upstream fixture test passes unchanged.
Two authorizer tests pinned the old contract that an idle session could
be closed from an unrelated authorizer; they now pin the rejection.
aduh95
pushed a commit
that referenced
this pull request
Sep 15, 2026
SQLite can invoke JavaScript conflict and filter callbacks while
applying a changeset. Copy the input first so detaching or modifying
its backing buffer during a callback does not affect the active
operation.
Signed-off-by: Matteo Collina <[email protected]>
PR-URL: #65286
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
aduh95
pushed a commit
that referenced
this pull request
Nov 13, 2026
SQLite can invoke JavaScript conflict and filter callbacks while
applying a changeset. Copy the input first so detaching or modifying
its backing buffer during a callback does not affect the active
operation.
Signed-off-by: Matteo Collina <[email protected]>
PR-URL: #65286
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewers
jasnell
jasnell approved these changes
trivikr
trivikr approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
author ready
PRs with CI started, the required approvals, and no outstanding review comments.
c++
Issues and PRs that require attention from people who are familiar with C++.
commit-queue-squash
PRs the Commit Queue should land as one squashed commit.
needs-ci
PRs that need a full CI run.
sqlite
Issues and PRs related to the SQLite subsystem.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|