Bug 785175: Discard column information if the script is too large instead of aborting. r=jorendorff
authorAlex Crichton <acrichton@mozilla.com>
Fri, 24 Aug 2012 09:47:42 -0700
changeset 105353 e5259919146b1cc402ad9f4b20217d612af91037
parent 105352 3f9d182bab1d254ed153205d4acdaf28998d602a
child 105354 3c0b16397ce910ca3e04ba058d4621d2609a5b80
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewersjorendorff
bugs785175
milestone17.0a1
Bug 785175: Discard column information if the script is too large instead of aborting. r=jorendorff
js/src/frontend/BytecodeEmitter.cpp
js/src/jit-test/tests/basic/bug785175.js
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -425,18 +425,22 @@ UpdateSourceCoordNotes(JSContext *cx, By
         return false;
 
     ptrdiff_t colspan = ptrdiff_t(pos.index) -
                         ptrdiff_t(bce->current->lastColumn);
     if (colspan != 0) {
         if (colspan < 0) {
             colspan += SN_COLSPAN_DOMAIN;
         } else if (colspan >= SN_COLSPAN_DOMAIN / 2) {
-            ReportStatementTooLarge(cx, bce->topStmt);
-            return false;
+            // If the column span is so large that we can't store it, then just
+            // discard this information because column information would most
+            // likely be useless anyway once the column numbers are ~4000000.
+            // This has been known to happen with scripts that have been
+            // minimized and put into all one line.
+            return true;
         }
         if (NewSrcNote2(cx, bce, SRC_COLSPAN, colspan) < 0)
             return false;
         bce->current->lastColumn = pos.index;
     }
     return true;
 }
 
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/bug785175.js
@@ -0,0 +1,9 @@
+var str = ' ';
+// Generate a 4MB string = 2^(20+2)
+for (var i = 0; i < 22; i++) {
+    str = str + str;
+}
+str += 'var a = 1 + 1;';
+
+// don't throw an exception even though the column numbers cannot be maintained
+eval(str);