Title: sqlite: two reentrancy guard gaps let a callback free the object SQLite is still using · Issue #65428 · nodejs/node · GitHub
Open Graph Title: sqlite: two reentrancy guard gaps let a callback free the object SQLite is still using · Issue #65428 · nodejs/node
X Title: sqlite: two reentrancy guard gaps let a callback free the object SQLite is still using · Issue #65428 · nodejs/node
Description: Version main (03fb384) Platform Darwin fcb214bb6048 25.6.0 Darwin Kernel Version 25.6.0: Fri Jul 31 19:19:08 PDT 2026; root:xnu-12377.161.14~5/RELEASE_ARM64_T6050 arm64 Subsystem sqlite What steps will reproduce the bug? Free memory that...
Open Graph Description: Version main (03fb384) Platform Darwin fcb214bb6048 25.6.0 Darwin Kernel Version 25.6.0: Fri Jul 31 19:19:08 PDT 2026; root:xnu-12377.161.14~5/RELEASE_ARM64_T6050 arm64 Subsystem sqlite What steps ...
X Description: Version main (03fb384) Platform Darwin fcb214bb6048 25.6.0 Darwin Kernel Version 25.6.0: Fri Jul 31 19:19:08 PDT 2026; root:xnu-12377.161.14~5/RELEASE_ARM64_T6050 arm64 Subsystem sqlite What steps ...
Opengraph URL: https://github.com/nodejs/node/issues/65428
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"sqlite: two reentrancy guard gaps let a callback free the object SQLite is still using","articleBody":"### Version\n\n`main` (03fb38410b2)\n\n### Platform\n\n```text\nDarwin fcb214bb6048 25.6.0 Darwin Kernel Version 25.6.0: Fri Jul 31 19:19:08 PDT 2026; root:xnu-12377.161.14~5/RELEASE_ARM64_T6050 arm64\n```\n\n### Subsystem\n\nsqlite\n\n### What steps will reproduce the bug?\n\nFree memory that SQLite is still using from a callback:\n\n```js\nimport { DatabaseSync, constants } from 'node:sqlite';\n\nconst db = new DatabaseSync(':memory:');\ndb.exec('CREATE TABLE t(a PRIMARY KEY)');\nconst session = db.createSession();\n\nlet once = true;\ndb.setAuthorizer((action, p1) => {\n if (action === constants.SQLITE_PRAGMA && p1 === 'table_xinfo' && once) {\n once = false;\n session.close();\n }\n return constants.SQLITE_OK;\n});\n\ndb.exec('INSERT INTO t VALUES (1)');\n```\n\n### How often does it reproduce? Is there a required condition?\n\nThe fault always occurs, but it's not always visible under the default allocator. Run with\n`MallocScribble=1 MallocPreScribble=1 MallocNanoZone=0` on macOS and you get exit 139 deterministically; without it, the script can exit 0.\n\n### What is the expected behavior? Why is that the expected behavior?\n\n`statement.close()` should throw `ERR_INVALID_STATE`. Per `doc/api/sqlite.md`:\n\n> An `ERR_INVALID_STATE` error is thrown if this statement is currently executing, which happens\n> when the method is called from a callback that the statement itself triggered, such as a\n> user-defined function, an aggregate function, or a `'sqlite.db.query'` subscriber.\n\n### What do you see instead?\n\nA use-after-free. Under `MallocScribble`, lldb stops in `sqlite3VdbeMemSetNull(pMem=0xaaaaaaaaaaaaaaaa)` with `EXC_BAD_ACCESS`.\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/TrevorBurnham","@type":"Person","name":"TrevorBurnham"},"datePublished":"2026-08-20T12:55:12Z","url":"https://github.com/nodejs/node/issues/65428"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4b48b535-ccee-099f-c545-cd382e226cc1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9758:32DB95:50EECE:6DD99C:6AED1DA8 |
| html-safe-nonce | a2bea0f2e916e9867b4b6d1225cbfee17bef3d8f32f69287ed36523b3cac5682 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NzU4OjMyREI5NTo1MEVFQ0U6NkREOTlDOjZBRUQxREE4IiwidmlzaXRvcl9pZCI6IjM2MTM1ODkyOTQ4MzcyMTA1MzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f16097856acd64f83618064fcd2cfed2cb7abb74c1b139ee5c815f92d68db395 |
| hovercard-subject-tag | issue:5203621819 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/65428/issue_layout |
| twitter:image | https://opengraph.githubassets.com/688925c15ea5ad0dad1a456125e6b75f6c6120de495f874d5842dc7ac1aaf070/nodejs/node/issues/65428 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/688925c15ea5ad0dad1a456125e6b75f6c6120de495f874d5842dc7ac1aaf070/nodejs/node/issues/65428 |
| og:image:alt | Version main (03fb384) Platform Darwin fcb214bb6048 25.6.0 Darwin Kernel Version 25.6.0: Fri Jul 31 19:19:08 PDT 2026; root:xnu-12377.161.14~5/RELEASE_ARM64_T6050 arm64 Subsystem sqlite What steps ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | TrevorBurnham |
| hostname | github.com |
| expected-hostname | github.com |
| None | e3e0f7f63e50c6fe879198a93a0a023a648ecc0a5e9bc3b5e033ac57172237e6 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 707a24b346ac8a82878b9c084efaa38a997660cb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width