Repository navigation
[do not merge] measure parse depth limits on 18.1.5 vs main per OS - #216
pyramation wants to merge 2 commits into
Conversation
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review complete. 🟠 1 high · 🟡 2 medium 💬 Inline comments (3)
This PR adds a
The probe should be wired in as a separate script (e.g. Reviewed commit: 1f6a08a |
|
Caution Review failedThe pull request is closed. Walkthrough
|
There was a problem hiding this comment.
Replaces the versions/18 test script with a new depth-probe diagnostic, dropping the full existing test suite.
Key findings
- 🟠 Test script drops all existing test suites — package.json:34
- 🟡 Probe test needs network and always passes — depth-probe.test.js:33
- 🟡 Probe conflates any thrown error with depth failure — depth-probe.test.js:26
| "wasm:clean": "pnpm wasm:make clean", | ||
| "wasm:clean-cache": "pnpm wasm:make clean-cache", | ||
| "test": "node --test test/parsing.test.js test/pg18.test.js test/fingerprint.test.js test/normalize.test.js test/plpgsql.test.js test/scan.test.js test/errors.test.js test/input-encoding.test.js test/wasm-recovery.test.js test/load-module.test.js" | ||
| "test": "node --test test/depth-probe.test.js" |
There was a problem hiding this comment.
🟠 bug · high
Test script drops all existing test suites
The test script in versions/18/package.json:34 now runs only test/depth-probe.test.js, replacing the original run of ten test suites (parsing, pg18, fingerprint, normalize, plpgsql, scan, errors, input-encoding, wasm-recovery, load-module). All ten files still exist in versions/18/test/ but are no longer executed by npm test, and no other script runs them. The entire regression suite, including error-handling and WASM-recovery coverage, silently stops running.
📋 Prompt for AI Agents
In versions/18/package.json line 34, restore the test script to run all existing suites (test/parsing.test.js test/pg18.test.js test/fingerprint.test.js test/normalize.test.js test/plpgsql.test.js test/scan.test.js test/errors.test.js test/input-encoding.test.js test/wasm-recovery.test.js test/load-module.test.js) and add a separate script such as "test:probe": "node --test test/depth-probe.test.js" so the new depth probe runs alongside, not instead of, the regression suite.
| it('probe', async () => { | ||
| const dir = path.join(__dirname, '..', '.probe'); | ||
| fs.mkdirSync(dir, { recursive: true }); | ||
| execSync('npm pack libpg-query@18.1.5 --silent', { cwd: dir }); | ||
| execSync('tar xzf libpg-query-18.1.5.tgz', { cwd: dir }); | ||
| const old = require(path.join(dir, 'package', 'wasm', 'index.cjs')); | ||
| const cur = require('../wasm/index.cjs'); | ||
| const out = [`node ${process.version} ${process.platform} ${process.arch}`]; | ||
| for (const [name, lib] of [['18.1.5', old], ['main', cur]]) { | ||
| for (const row of await measure(lib)) out.push(`PROBE ${name} | ${row}`); | ||
| } | ||
| console.log(out.join('\n')); | ||
| }); |
There was a problem hiding this comment.
🟡 bug · medium
Probe test needs network and always passes
The probe test runs npm pack libpg-query@18.1.5 on every run (versions/18/test/depth-probe.test.js:36), requiring registry network access and a hardcoded version pin, and extracts into versions/18/.probe with no cleanup and no .gitignore entry. Its single it('probe') body only prints rows and contains no assertions, so the test can never fail; combined with it being the sole npm test entry point (see finding-001), any offline CI fails the whole suite while regressions go undetected.
📋 Prompt for AI Agents
In versions/18/test/depth-probe.test.js lines 33-45, make the probe robust: skip the test (e.g. t.skip) when the registry is unreachable or the tarball is already cached, read the version from package.json instead of the hardcoded '18.1.5', clean up versions/18/.probe (fs.rmSync in an after hook or extract to a temp dir; also add .probe/ to .gitignore), and add assertions on the rows collected in measure() — or move the probe to a separate opt-in script since it is not a regression test.
| const top = err; | ||
| while (lo < hi - 1) { const mid = (lo + hi) >> 1; if (ok(mid)) lo = mid; else hi = mid; } | ||
| ok(hi); | ||
| rows.push(`${form} ${fn}: max ${lo} (at ${hi}: ${err}; at 20000: ${top})`); |
There was a problem hiding this comment.
🟡 bug · medium
Probe conflates any thrown error with depth failure
The ok helper in versions/18/test/depth-probe.test.js:26 treats every thrown error as a depth-limit failure, so out-of-memory errors (libpg_query ran out of WASM memory, allocation failures), WASM traps, and ordinary parse errors all terminate the binary search the same way a stack depth limit exceeded error would. For large-input forms like chained +1, the search can converge on the WASM heap limit rather than the parser stack limit and report a bogus maximum. The typeof r === 'string' && /memory exhausted|stack depth/ branch is dead code: the sync APIs throw on errors and never return error strings.
📋 Prompt for AI Agents
In versions/18/test/depth-probe.test.js line 26, rewrite ok so the catch branch inspects e.message: return false as a depth failure only when the message contains 'stack depth limit exceeded'; if it matches /out of (WASM )?memory|memory allocation failed|terminated/ set err to a distinct marker (e.g. 'oom'); for any other message record the message and abort the measurement rather than treating it as a depth failure. Remove the dead typeof r === 'string' regex branch since the sync APIs throw rather than return error strings.
|
Measurement only, closing. 18.1.5 and main reach the same depths within a few levels on all three OSes; only normalize of nested function calls on Linux/Windows drops from 838 to 781. |
Summary
Temporary: replaces the v18 test run with a probe that binary-searches the deepest nested function calls, subqueries, chained
+1and PL/pgSQLIFblocks thatparseSync/normalizeSync/parsePlPgSQLSyncaccept, on published libpg-query 18.1.5 and on the main build, so we get the numbers from the macOS and Windows runners. Will be closed without merging.Implemented in session Settle the last old WASM hardening PRs
Review with Devin · Open in Devin Desktop
Summary by CodeRabbit