Skip to content

src: fix crash in GetErrorSource() for invalid using syntax#62770

Open
semimikoh wants to merge 1 commit intonodejs:mainfrom
semimikoh:fix-geterrorsource-crash
Open

src: fix crash in GetErrorSource() for invalid using syntax#62770
semimikoh wants to merge 1 commit intonodejs:mainfrom
semimikoh:fix-geterrorsource-crash

Conversation

@semimikoh
Copy link
Copy Markdown
Contributor

@semimikoh semimikoh commented Apr 16, 2026

Fixes: #62767

V8 can report an invalid source range for some malformed using and
await using declarations, with the end column preceding the start
column. GetErrorSource() currently asserts that the end column is
greater than or equal to the start column before reaching the existing
bounds check, so formatting the SyntaxError aborts the process.

Remove the assertion and only apply the script start offset when both
columns can be adjusted. Invalid ranges now fall through to the existing
fallback path, which prints the error source without an underline instead
of crashing.

Add regression coverage for the four invalid using / await using
cases reported from test262.

Refs: https://github.com/tc39/test262

Verification

$ ./tools/test.py -J --mode=release test/parallel/test-cli-eval-invalid-using.js

All tests passed.

$ out/Release/node tools/eslint/node_modules/eslint/bin/eslint.js --cache test/parallel/test-cli-eval-invalid-using.js

No lint errors.

$ tools/cpplint.py src/node_errors.cc

Done processing src/node_errors.cc

$ git diff --check -- src/node_errors.cc test/parallel/test-cli-eval-invalid-using.js

No whitespace errors.

@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. labels Apr 16, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 16, 2026

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.69%. Comparing base (d080801) to head (89b1cf8).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
src/node_errors.cc 0.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62770      +/-   ##
==========================================
- Coverage   91.55%   89.69%   -1.86%     
==========================================
  Files         355      706     +351     
  Lines      149381   218127   +68746     
  Branches    23364    41738   +18374     
==========================================
+ Hits       136765   195652   +58887     
- Misses      12354    14397    +2043     
- Partials      262     8078    +7816     
Files with missing lines Coverage Δ
src/node_errors.cc 64.68% <0.00%> (ø)

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

Comment on lines +10 to +11
'async function f() { { await using x=null, []=null; } }',
'async function f() { { await using x=null, {}=null; } }',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
'async function f() { { await using x=null, []=null; } }',
'async function f() { { await using x=null, {}=null; } }',
'async function f() { await using x=null, []=null; }',
'async function f() { await using x=null, {}=null; }',

or even

Suggested change
'async function f() { { await using x=null, []=null; } }',
'async function f() { { await using x=null, {}=null; } }',
'{ await using x=null, []=null; }',
'{ await using x=null, {}=null; }',

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash in '{using x=null, {}=null;}'

3 participants