Bug 1308048 - Ensure off-thread parse task's script is rooted correctly r=jandem a=abillings,ritu
authorJon Coppeard <jcoppeard@mozilla.com>
Fri, 07 Oct 2016 13:58:37 +0200
changeset 350629 3d2ba22eee02c115699d0558d1f3a15a159051b6
parent 350628 f4385d3a94d43a159e42326ff9ad3615260fa22a
child 350630 3a88afcbfdc410d3b67e051568e53ba8bdfbf823
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem, abillings, ritu
bugs1308048
milestone50.0
Bug 1308048 - Ensure off-thread parse task's script is rooted correctly r=jandem a=abillings,ritu
js/src/jit-test/tests/gc/bug-1308048.js
js/src/vm/HelperThreads.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/gc/bug-1308048.js
@@ -0,0 +1,10 @@
+if (helperThreadCount() == 0)
+    quit();
+
+m = 'x';
+for (var i = 0; i < 10; i++)
+    m += m;
+offThreadCompileScript("", ({elementAttributeName: m}));
+var n = newGlobal();
+gczeal(2,1);
+n.runOffThreadScript();
--- a/js/src/vm/HelperThreads.cpp
+++ b/js/src/vm/HelperThreads.cpp
@@ -1171,22 +1171,22 @@ GlobalHelperThreadState::finishParseTask
     Rooted<GlobalObject*> global(cx, &cx->global()->as<GlobalObject>());
     if (!EnsureParserCreatedClasses(cx, kind)) {
         LeaveParseTaskZone(cx, parseTask);
         return nullptr;
     }
 
     mergeParseTaskCompartment(cx, parseTask, global, cx->compartment());
 
+    RootedScript script(cx, parseTask->script);
+    releaseAssertSameCompartment(cx, script);
+
     if (!parseTask->finish(cx))
         return nullptr;
 
-    RootedScript script(cx, parseTask->script);
-    releaseAssertSameCompartment(cx, script);
-
     // Report out of memory errors eagerly, or errors could be malformed.
     if (parseTask->outOfMemory) {
         ReportOutOfMemory(cx);
         return nullptr;
     }
 
     // Report any error or warnings generated during the parse, and inform the
     // debugger about the compiled scripts.