Bug 1466387 - Set up the gray root tracer on worker thread. r=jonco, a=RyanVM
authorSteve Fink <sfink@mozilla.com>
Tue, 05 Jun 2018 16:03:36 -0700
changeset 471293 5fafd6ba99e4
parent 471292 a5aa390759bf
child 471294 e5d9bf645ebf
push id9356
push userryanvm@gmail.com
push dateTue, 12 Jun 2018 20:44:56 +0000
treeherdermozilla-beta@5fafd6ba99e4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco, RyanVM
bugs1466387
milestone61.0
Bug 1466387 - Set up the gray root tracer on worker thread. r=jonco, a=RyanVM
js/src/shell/js.cpp
js/src/tests/non262/regress/regress-1466387-worker-grayroot.js
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -3580,16 +3580,17 @@ WorkerMain(void* arg)
         CancelOffThreadJobsForContext(cx);
         JS_DestroyContext(cx);
         js_delete(sc);
         js_delete(input);
     });
 
     sc->isWorker = true;
     JS_SetContextPrivate(cx, sc);
+    JS_SetGrayGCRootsTracer(cx, TraceGrayRoots, nullptr);
     SetWorkerContextOptions(cx);
     JS::SetBuildIdOp(cx, ShellBuildId);
 
     JS_SetFutexCanWait(cx);
     JS::SetWarningReporter(cx, WarningReporter);
     js::SetPreserveWrapperCallback(cx, DummyPreserveWrapperCallback);
     JS_InitDestroyPrincipalsCallback(cx, ShellPrincipals::destroy);
 
new file mode 100644
--- /dev/null
+++ b/js/src/tests/non262/regress/regress-1466387-worker-grayroot.js
@@ -0,0 +1,28 @@
+var BUGNUMBER = 1466387;
+var summary = 'grayRoot() testing on worker thread';
+
+// Before bug 1466387, the gray root tracer was not set up on worker threads,
+// but the grayRoot() function was still available. This resulted in a GC
+// collecting the gray root, then a read barrier firing on the dead object.
+//
+// This is a crashtest. If it does not crash, it will throw a ReferenceError,
+// but that's ok.
+
+print('BUGNUMBER: ' + BUGNUMBER);
+print("STATUS: " + summary);
+
+if (typeof 'evalInWorder' == 'function') {
+    evalInWorker(`
+  var wm = new WeakMap();
+  grayRoot().map = wm;
+  gczeal(4,10);
+  evaluate(\`
+  grayRoot().map = __v_1173;
+  if (!class i   { constructor() { } }  ()) {
+    (function __f_252( get       ,    )  {})();
+  }
+  \`);
+`);
+}
+
+this.reportCompare && reportCompare(true, true, summary);