New issue
Advanced search Search tips

Issue 797581 link

Starred by 2 users

Issue metadata

Status: Verified
Owner:
Closed: Jan 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug



Sign in to add a comment

Ill in v8::internal::AstNumberingVisitor::VisitEmptyParentheses

Project Member Reported by ClusterFuzz, Dec 25 2017

Issue description

Detailed report: https://clusterfuzz.com/testcase?key=4570742481223680

Fuzzer: libFuzzer_javascript_parser_proto_fuzzer
Job Type: libfuzzer_chrome_asan
Platform Id: linux

Crash Type: Ill
Crash Address: 0x000002510aa8
Crash State:
  v8::internal::AstNumberingVisitor::VisitEmptyParentheses
  v8::internal::AstNumberingVisitor::VisitNoStackOverflowCheck
  v8::internal::AstNumberingVisitor::VisitStatements
  
Sanitizer: address (ASAN)

Regressed: https://clusterfuzz.com/revisions?job=libfuzzer_chrome_asan&range=524603:524604

Reproducer Testcase: https://clusterfuzz.com/download?testcase_id=4570742481223680

Issue filed automatically.

See https://chromium.googlesource.com/chromium/src/+/master/testing/libfuzzer/reference.md for more information.
 
Project Member

Comment 1 by ClusterFuzz, Dec 25 2017

Components: Blink>JavaScript>Language
Labels: Test-Predator-Auto-Components
Automatically applying components based on crash stacktrace and information from OWNERS files.

If this is incorrect, please apply the Test-Predator-Wrong-Components label.
Owner: marja@chromium.org
Status: Assigned (was: Untriaged)
Cc: metzman@chromium.org mmoroz@chromium.org
Components: Blink>JavaScript>Parser

Comment 4 by marja@chromium.org, Jan 8 2018

Cc: neis@chromium.org leszeks@chromium.org
The repro case is:

foo.js:
export default (   )

Ran like this:

d8 --module foo.js


Comment 5 by marja@chromium.org, Jan 8 2018

And the bug is that we reach this code:

void AstNumberingVisitor::VisitEmptyParentheses(EmptyParentheses* node) {
  UNREACHABLE();
}

Comment 6 by neis@chromium.org, Jan 9 2018

Labels: -Pri-1 Pri-2

Comment 7 by marja@chromium.org, Jan 9 2018

Update:

So, we need to somehow disallow "export default ()", which uses "()" as an expression (ParseAssignmentExpression returns EmptyParenthesis). "()" is already disallowed as an expression in other places, and the checks are in various places in the code too:

let x = (); << ValidateExpression called from ParseVariableDeclarations

if (()) { ... } << ValidateExpression called from ParseExpression, called from ParseIfStatement


I thought the fix would be:

ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN, bool* ok) {
  ...
  ExpressionT expression;
  if (IsTrivialExpression()) {
    expression = ParsePrimaryExpression(&is_async, CHECK_OK);
  } else {
    expression = ParseConditionalExpression(accept_IN, CHECK_OK);
  }
  ...

  if (peek() == Token::ARROW) {
   ...
   return expression;
+  } else {
+    ValidateExpression(CHECK_OK);
   }


But that's not the correct fix - and I don't understand why.

Apparently in many cases, e.g., here:

((x, {y = x}) => assertEquals(42, y))(42, {});
      ^^^^^

is_valid_expression() is false (because of "Invalid shorthand property initializer").

I don't understand what is_valid_expression() means, since "y = x" is a valid expression...

---------------


However, a less generic fix https://chromium-review.googlesource.com/#/c/v8/v8/+/856937 seems to work. But still, I'd like to understand why the more generic fix is not correct...

Comment 8 by adamk@chromium.org, Jan 9 2018

The "invalid expression" here isn't "y = x", but "{y = x}" (which is indeed an invalid expression). The trouble with the proposed generic fix is that it's not required that the left-hand-side of an AssignmentPattern be an expression (indeed, "{y = x}" is one such valid LHS but invalid expression).

As it happens, "()" is both an invalid LHS _and_ an invalid expression, but I think the fix in the linked CL (which does the checking just outside ParseAssignmentExpression) is the right fix.

Comment 9 by marja@chromium.org, Jan 10 2018

Ahh, this makes perfect sense. Thanks, adamk@.
Project Member

Comment 10 by bugdroid1@chromium.org, Jan 10 2018

Comment 11 by marja@chromium.org, Jan 10 2018

Status: Fixed (was: Assigned)
Project Member

Comment 12 by ClusterFuzz, Jan 11 2018

ClusterFuzz has detected this issue as fixed in range 528344:528345.

Detailed report: https://clusterfuzz.com/testcase?key=4570742481223680

Fuzzer: libFuzzer_javascript_parser_proto_fuzzer
Job Type: libfuzzer_chrome_asan
Platform Id: linux

Crash Type: Ill
Crash Address: 0x000002510aa8
Crash State:
  v8::internal::AstNumberingVisitor::VisitEmptyParentheses
  v8::internal::AstNumberingVisitor::VisitNoStackOverflowCheck
  v8::internal::AstNumberingVisitor::VisitStatements
  
Sanitizer: address (ASAN)

Regressed: https://clusterfuzz.com/revisions?job=libfuzzer_chrome_asan&range=524603:524604
Fixed: https://clusterfuzz.com/revisions?job=libfuzzer_chrome_asan&range=528344:528345

Reproducer Testcase: https://clusterfuzz.com/download?testcase_id=4570742481223680

See https://chromium.googlesource.com/chromium/src/+/master/testing/libfuzzer/reference.md for more information.

If you suspect that the result above is incorrect, try re-doing that job on the test case report page.
Project Member

Comment 13 by ClusterFuzz, Jan 11 2018

Labels: ClusterFuzz-Verified
Status: Verified (was: Fixed)
ClusterFuzz testcase 4570742481223680 is verified as fixed, so closing issue as verified.

If this is incorrect, please add ClusterFuzz-Wrong label and re-open the issue.

Sign in to add a comment