Repository navigation
fix(javascript): handle oversized inline source maps - #1386
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
TL;DR: This fixes the crash from the issue. One hostile input still crashes the whole run. What passes
What still failsA long run of spaces in a 'ğ//# sourceMappingURL=' + ' '.repeat(9_500_000) + 'x'It throws End to end, it kills the whole run. The CLI returns Not run
Thanks, cold-atom, for the quick fix! A possible shapeDrop the regex for the prefix. Match the fixed text with const skip = c.slice(i).search(/\S/u);
if (skip === -1) continue;
i += skip;
if (!c.startsWith("sourceMappingURL", i)) continue;
const end = c.slice(i).search(/[\s*]/u);I tried this shape locally. It handled 9.5M spaces in each of the three slots. It passed on both Nodes. Test setup
🤖 Generated with Claude Code (Opus 5.5) 🦊 |
|
TL;DR: On Node 26 this PR passes every case. That includes the hostile one. That one still fails on 22 and 24. Earlier I said Node 26 was not run. Here it is. I used head
So Node 26 handles the long 🤖 Generated with Claude Code (Opus 5.5) 🦊 |
|
Thanks for the additional testing. I pushed commit b117b12, which replaces the unbounded source-map prefix regex with fixed-text checks and bounded searches. It also adds regression coverage for the 9.5M-space cases. The earlier results were against 3a28bc0; please retest the latest PR head when the checks are available. |
N0zoM1z0
left a comment
There was a problem hiding this comment.
Reviewed final head b117b12. Fixed-prefix checks plus single-class searches cover both the oversized URL and long whitespace cases without regexp backtracking. The 34 focused tests pass; the same real application fails on main and succeeds via public CLI on Node 22/24. Real stdio MCP preserves the transport diagnostic and exports complete retained Evidence successfully. All final-head checks are green. Large result delivery remains a separate follow-up.
|
TL;DR: The new commit fixes the last crash. Every case I had now passes on Node 22, 24 and 26.
The 34 tests are the 21 old ones plus your 13 new ones. The hostile app used to exit 1 on 22 and 24. Now it exits 0. The output holds the full 9.6M map URL. I also tried a few extra shapes. Spaces in all three slots at once pass. So do the Your new tests do catch the old bug. I ran them against I also looked for slow inputs. The new searches each scan once, so they stay linear. I built a 5.5 MB file with 200k near-miss lines. It took under 0.2 seconds on each Node. A 3.3 MB file with 10k real directives is slow. It took 33 to 40 seconds here. Release 6.3.0 is slow on it too. The time goes to older code, not your change. Not run
Thanks, cold-atom, for the quick turnaround! Test setup
🤖 Generated with Claude Code (Opus 5.5) 🦊 |
|
TL;DR: I ran the full test suite on this PR. It passes on Node 22, 24 and 26. Nothing failed. My last note listed the full suite as not run. Here it is.
The skips come from macOS, Windows and host checks in the tests. Linux skips them by design. oxlint shows warnings but no errors. None are in the two files this PR changes. The lint script then runs a boundary check, which needs git. Not run
Thanks again, cold-atom! Commandsnpm ci
npm run compile
node scripts/generate-mcp-tool-catalog.mjs
node scripts/generate-skill-metadata.mjs
node scripts/generate-product-catalog.mjs
node scripts/generate-completion-ledger.mjs
npm run typecheck
npm run lint
npm run format:check
node node_modules/vitest/vitest.mjs runTest setup
🤖 Generated with Claude Code (Opus 5.5) 🦊 |
* fix(javascript): handle oversized inline source maps * fix(javascript): avoid source map directive regex overflow
A large inline source-map directive in a two-byte JavaScript source can overflow V8's regexp stack before application analysis finishes. Read the directive with fixed-prefix checks and single-character-class searches, preserving complete declared URLs and source ranges. This also handles long whitespace before the name, equals sign, and URL.
Fixes #1380.
Validation of final head
b117b121:npm run test:focused -- src/domain/javascript/javascriptStaticAnalysisSourceMaps.test.ts: 34 passed.7aa4d768and succeeds here; its 9,600,223-character inline URL and three 9.5M-space directive variants retain exact URLs.No Hopper/Ghidra verification was needed for this JavaScript parser change.