Bug 1203695 - GenerateLcovInfo: Check if JSScripts have associated bytecode before spewing their content. r=bhackett
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Wed, 16 Sep 2015 21:11:36 +0200
changeset 297180 cdbdb471f9c790e5f8f3e0a4cc372ff5266af2e3
parent 297179 26ca3396791f227f6402bb51a58ff727784ca939
child 297181 b4f94fa3627dd5dc02cc1bf68345e51176e06c97
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs1203695
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1203695 - GenerateLcovInfo: Check if JSScripts have associated bytecode before spewing their content. r=bhackett
js/src/jit-test/tests/coverage/bug1203695.js
js/src/jsopcode.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/coverage/bug1203695.js
@@ -0,0 +1,14 @@
+
+var lfcode = new Array();
+lfcode.push = loadFile;
+lfcode.push(")");
+lfcode.push(`
+assertThrowsInstanceOf(function () {}, TypeError);
+var g = newGlobal();
+`);
+getLcovInfo(g);
+function loadFile(lfVarx) {
+    try {
+        evaluate(lfVarx, { noScriptRval : true, compileAndGo : true });
+    } catch (lfVare) {}
+}
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -2106,16 +2106,23 @@ GenerateLcovInfo(JSContext* cx, JSCompar
     // Collect the list of scripts which are part of the current compartment.
     Rooted<ScriptVector> topScripts(cx, ScriptVector(cx));
     for (ZonesIter zone(rt, SkipAtoms); !zone.done(); zone.next()) {
         for (ZoneCellIter i(zone, AllocKind::SCRIPT); !i.done(); i.next()) {
             JSScript* script = i.get<JSScript>();
             if (script->compartment() != comp)
                 continue;
 
+            // If we evaluate some code which contains a syntax error, then we
+            // might produce a JSScript which has no associated bytecode. This
+            // line filters out this kind of scripts.
+            if (!script->code())
+                continue;
+
+            // Filter out any JSScript which is not the top-level of a file.
             if (script->functionNonDelazifying())
                 continue;
 
             if (!topScripts.append(script))
                 return false;
         }
     }