Revision: 19845
Author:   [email protected]
Date:     Wed Mar 12 13:27:32 2014 UTC
Log:      Parser: fix confusion when there are multiple errors to report.

(For more details, see bug.)

The problem occurs when a parsing function hits a stack overflow, but still
manages to return something meaningful. This happens because the call to
ParserBase::Next() which hits the stack overflow will still return a valid token
(the last token which we had already read), and only the next call after the
stack overflow will return INVALID. So for example ParseIdentifier will still
return a valid identifier even if we've hit a stack overflow.

In this case, some upper recursion level might detect and report a valid syntax
error, and then we bail out of the recursive descent because of the syntax
error. So we end up having both stack overflow and a syntax error present. When we try to report the stack overflow after parsing (e.g., end of ParseLazy), the isolate already has the syntax error as a pending exception, and a CHECK fails.

This fix suppresses the syntax errors in when a stack overflow has been
detected.

BUG=351335
LOG=N
[email protected]

Review URL: https://codereview.chromium.org/194713013
http://code.google.com/p/v8/source/detail?r=19845

Modified:
 /branches/bleeding_edge/src/parser.cc

=======================================
--- /branches/bleeding_edge/src/parser.cc       Tue Mar 11 16:30:47 2014 UTC
+++ /branches/bleeding_edge/src/parser.cc       Wed Mar 12 13:27:32 2014 UTC
@@ -452,6 +452,12 @@
 void ParserTraits::ReportMessageAt(Scanner::Location source_location,
                                    const char* message,
                                    Vector<const char*> args) {
+  if (parser_->stack_overflow()) {
+ // Suppress the error message (syntax error or such) in the presence of a + // stack overflow. The isolate allows only one pending exception at at time
+    // and we want to report the stack overflow later.
+    return;
+  }
   MessageLocation location(parser_->script_,
                            source_location.beg_pos,
                            source_location.end_pos);
@@ -477,6 +483,12 @@
 void ParserTraits::ReportMessageAt(Scanner::Location source_location,
                                    const char* message,
                                    Vector<Handle<String> > args) {
+  if (parser_->stack_overflow()) {
+ // Suppress the error message (syntax error or such) in the presence of a + // stack overflow. The isolate allows only one pending exception at at time
+    // and we want to report the stack overflow later.
+    return;
+  }
   MessageLocation location(parser_->script_,
                            source_location.beg_pos,
                            source_location.end_pos);

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to