src: fix crash in GetErrorSource() for invalid using syntax#62770
src: fix crash in GetErrorSource() for invalid using syntax#62770semimikoh wants to merge 3 commits intonodejs:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #62770 +/- ##
==========================================
- Coverage 89.62% 89.60% -0.02%
==========================================
Files 706 706
Lines 219136 219134 -2
Branches 41987 41981 -6
==========================================
- Hits 196404 196365 -39
- Misses 14611 14657 +46
+ Partials 8121 8112 -9
🚀 New features to boost your workflow:
|
| 'async function f() { { await using x=null, []=null; } }', | ||
| 'async function f() { { await using x=null, {}=null; } }', |
There was a problem hiding this comment.
| '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
| '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; }', |
There was a problem hiding this comment.
V8 doesn't guarantee that these will behave in an ordered way, so this looks like a worthwhile change.
However, the test case is probably a genuine V8 parser bug (the message's end_position ends up being one less than its start_position, hence the previous assertion failure), so I'm not sure that it's worthwhile hard-coding this as a Node.js test; the quirky behaviour it relies upon is liable to be patched upstream.
Agreed. This test case could be a clunky failure when V8 is upgraded. We can remove the test. |
| @@ -150,8 +150,7 @@ static std::string GetErrorSource(Isolate* isolate, | |||
| : 0; | |||
| int start = message->GetStartColumn(context).FromMaybe(0); | |||
| int end = message->GetEndColumn(context).FromMaybe(0); | |||
| if (start >= script_start) { | |||
| CHECK_GE(end, start); | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Thanks for the reviews! |
50e788d to
2e11a9f
Compare
2e11a9f to
81a0a95
Compare
Fixes: #62767
V8 can report an invalid source range for some malformed
usingandawait usingdeclarations, with the end column preceding the startcolumn.
GetErrorSource()currently asserts that the end column isgreater 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 usingcases reported from test262.
Refs: https://github.com/tc39/test262
Verification