Skip to content

sqlite: reject statement-less SQLTagStore queries - #65152

Open
lazerg wants to merge 2 commits into
nodejs:mainfrom
lazerg:fix/issue-65149-tagstore-comment-only
Open

sqlite: reject statement-less SQLTagStore queries#65152
lazerg wants to merge 2 commits into
nodejs:mainfrom
lazerg:fix/issue-65149-tagstore-comment-only

Conversation

@lazerg

@lazerg lazerg commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Fixes: #65149

A query that holds no statement, such as sql.run`-- comment`, segfaults every SQLTagStore method. sqlite3_prepare_v2() returns SQLITE_OK with a null sqlite3_stmt* for input that is only a comment or whitespace, and ResetAndBindStatement() passes that null pointer straight to sqlite3_clear_bindings().

StatementSync already models a null statement as finalized, so this checks for it and throws ERR_INVALID_STATE, the same error db.prepare('-- comment').run() gives today.

Signed-off-by: Lazizbek Ergashev <lazerg2@gmail.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/sqlite

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem. labels Aug 9, 2026
@codecov

codecov Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.32%. Comparing base (a876a12) to head (3ff24e1).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #65152   +/-   ##
=======================================
  Coverage   90.32%   90.32%           
=======================================
  Files         759      759           
  Lines      248325   248345   +20     
  Branches    46861    46875   +14     
=======================================
+ Hits       224303   224322   +19     
+ Misses      15467    15462    -5     
- Partials     8555     8561    +6     
Files with missing lines Coverage Δ
src/node_sqlite.cc 81.39% <100.00%> (+0.16%) ⬆️

... and 31 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.

@Renegade334 Renegade334 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#65157 is the correct approach here, there's no point in allowing a null statement to be constructed and added to the tag store cache in the first place. We should reject these at the point of preparation.

That being said, this should also be the case for db.prepare()

Comment thread src/node_sqlite.cc Outdated
Signed-off-by: Lazizbek Ergashev <lazerg2@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sqlite: segfault when a SQLTagStore query contains only a comment

5 participants