help icon indicating copy to clipboard operation
help copied to clipboard

Guidance requested: intermittent crash during `node:sqlite` statement preparation

Open polikoffyantzica2-cpu opened this issue 1 month ago • 1 comments

Node.js Version

v25.6.1

NPM Version

Not recorded for the captured crash

Operating System

macOS ARM64

Subsystem

sqlite

Description

We observed an intermittent native crash during synthetic integration tests of a desktop application on macOS ARM64 using Node.js v25.6.1 and node:sqlite.

In a later targeted run, the process stopped with EXC_BAD_ACCESS while preparing a SQL statement. The relevant stack included sqlite3WalkExprNN, sqlite3Prepare, and node::sqlite::DatabaseSync::Prepare.

An earlier test run also crashed during SQLite statement preparation, but its exact SQL was not captured. We cannot establish whether the two crashes share a cause.

Node reported SQLite 3.51.2 as its compile-time version, while the dynamically loaded SQLite library reported 3.53.3. We do not know whether that difference is relevant. An integrity check on a copy of the synthetic database returned ok; a subsequent targeted test passed, but that does not demonstrate a fix.

We do not yet have a standalone reproducible example. What supported, low-overhead diagnostic information would be most useful to distinguish an application lifecycle issue from a Node.js or SQLite issue? Are there known compatibility considerations for this compile-time and dynamically loaded SQLite version combination?

This is a request for diagnostic guidance, not a claim that a Node.js or SQLite defect has been established. We can provide a separately reviewed synthetic SQL example if useful.

Minimal Reproduction

No response

Output

No response

Before You Submit

  • [x] I have looked for issues that already exist before submitting this
  • [x] My issue follows the guidelines in the README file, and follows the 'How to ask a good question' guide at https://stackoverflow.com/help/how-to-ask

polikoffyantzica2-cpu avatar Oct 27 '26 05:10 polikoffyantzica2-cpu

For this report I would separate library/build identity from the statement and connection lifecycle, rather than treating either the version mismatch or the successful retry as a diagnosis.

Small, once-per-process snapshot

Run this with a connection owned by the same process/thread that runs the failing prepare, before the synthetic test starts. prepare() is synchronous and get()/all() are public APIs in the exact v25.6.1 docs.

function sqliteSnapshot(db) {
  return {
    node: process.version,
    platform: process.platform,
    arch: process.arch,
    executable: process.execPath,
    reportedSqlite: process.versions.sqlite,
    runtimeSqlite: db.prepare(
      'SELECT sqlite_version() AS version, sqlite_source_id() AS sourceId'
    ).get(),
    compileOptions: db.prepare('PRAGMA compile_options').all()
      .map(row => row.compile_options),
    loadedSqliteObjects: process.report.getReport().sharedObjects
      .filter(name => /sqlite/i.test(name)),
  };
}
console.error(JSON.stringify(sqliteSnapshot(db)));

SQLite distinguishes the runtime library version/source ID from the header macros. Recording the source ID and compile options gives maintainers more to compare than two version strings. Also state whether this is an official Node binary, a package-manager build, an embedded runtime, or a custom --shared-sqlite build. A different runtime version warrants checking that build/linkage, but does not by itself establish an ABI failure or the cause of this crash.

The snapshot prints an allowlist, not the full diagnostic report: full reports include environment variables by default. Review executable/library paths before sharing them. An empty loadedSqliteObjects list is not evidence that SQLite is absent; the library may be statically linked.

Correlate the next failure without logging application data

  • Assign each connection and synthetic statement a short ID. Log prepare-begin immediately before db.prepare() and prepare-ok immediately after it, along with PID, worker/thread ID and connection-close events. This identifies the last attempted statement even if the native crash prevents JS error handling. Avoid bound values or real user SQL; keep the reviewed synthetic SQL separately.
  • Attach the relevant macOS crash-report stack and loaded-image details, including the actual executable and SQLite library/build identities. A Node diagnostic report is useful supplementary data, but --report-on-fatalerror should not be assumed to catch every native EXC_BAD_ACCESS.
  • Compare the same reviewed synthetic case and database copy against an official Node binary of the same version, if available for your architecture. Keep the application build as a separate run and preserve failure counts, not just the last passing attempt. This can help distinguish build/linkage-specific behavior without declaring either run a fix.

I checked the snapshot's queries and output with Node 24.9.0 on Linux, against an in-memory database. I have not reproduced your Node 25.6.1/macOS ARM64 crash, and the snapshot is diagnostic collection, not a workaround or a supported-version compatibility verdict.

cryptostrapon avatar Nov 16 '26 16:11 cryptostrapon