Commit 43cdd62e authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[parser] Alternative fix to chromium:899495

If PreParser::ParseFormalParameterList detects a stack overflow, make
PreParseFunction actually return kPreParseStackOverflow.

BUG=chromium:899495

Change-Id: I1f347b56c594c6edd25401b8448ff38117e190a9
Reviewed-on: https://chromium-review.googlesource.com/c/1304536
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57103}
parent 9348047a
......@@ -2835,6 +2835,7 @@ bool Parser::SkipFunction(
// Propagate stack overflow.
set_stack_overflow();
} else if (pending_error_handler()->has_error_unidentifiable_by_preparser()) {
DCHECK(!pending_error_handler()->stack_overflow());
// If we encounter an error that the preparser can not identify we reset to
// the state before preparsing. The caller may then fully parse the function
// to identify the actual error.
......@@ -2843,8 +2844,10 @@ bool Parser::SkipFunction(
pending_error_handler()->clear_unidentifiable_error();
return false;
} else if (pending_error_handler()->has_pending_error()) {
DCHECK(!pending_error_handler()->stack_overflow());
DCHECK(scanner()->has_parser_error());
} else {
DCHECK(!pending_error_handler()->stack_overflow());
set_allow_eval_cache(reusable_preparser()->allow_eval_cache());
PreParserLogger* logger = reusable_preparser()->logger();
......
......@@ -159,10 +159,14 @@ PreParser::PreParseResult PreParser::PreParseFunction(
// We return kPreParseSuccess in failure cases too - errors are retrieved
// separately by Parser::SkipLazyFunctionBody.
ParseFormalParameterList(&formals);
RETURN_IF_PARSE_ERROR_VALUE(
pending_error_handler()->has_error_unidentifiable_by_preparser()
? kPreParseNotIdentifiableError
: kPreParseSuccess);
if (pending_error_handler()->stack_overflow()) {
return kPreParseStackOverflow;
} else if (pending_error_handler()
->has_error_unidentifiable_by_preparser()) {
return kPreParseNotIdentifiableError;
} else if (scanner()->has_parser_error()) {
return kPreParseSuccess;
}
Expect(Token::RPAREN);
RETURN_IF_PARSE_ERROR_VALUE(kPreParseSuccess);
int formals_end_position = scanner()->location().end_pos;
......
......@@ -66,7 +66,6 @@ class PendingCompilationErrorHandler {
void clear_unidentifiable_error() {
has_pending_error_ = false;
unidentifiable_error_ = false;
stack_overflow_ = false;
}
bool has_error_unidentifiable_by_preparser() const {
return unidentifiable_error_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment