diff --git a/js/src/jit-test/tests/basic/bug1344315.js b/js/src/jit-test/tests/basic/bug1344315.js new file mode 100644 index 0000000000000..b67b274f9cdcc --- /dev/null +++ b/js/src/jit-test/tests/basic/bug1344315.js @@ -0,0 +1,3 @@ +if (helperThreadCount() === 0) + quit(); +evalInCooperativeThread('cooperativeYield(); var dbg = new Debugger();'); diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index 9fd4cab8293ef..7f8986aa43bb2 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -342,6 +342,13 @@ JSRuntime::destroyRuntime() static void CheckCanChangeActiveContext(JSRuntime* rt) { + // The runtime might not currently have an active context, in which case + // the accesses below to ActiveThreadData data would not normally be + // allowed. Suppress protected data checks so these accesses will be + // tolerated --- if the active context is null then we're about to set it + // to the current thread. + AutoNoteSingleThreadedRegion anstr; + MOZ_RELEASE_ASSERT(!rt->activeContextChangeProhibited()); MOZ_RELEASE_ASSERT(!rt->activeContext() || rt->gc.canChangeActiveContext(rt->activeContext())); diff --git a/js/src/vm/Runtime.h b/js/src/vm/Runtime.h index 8ce1dfdf0fe5d..a1d6f3901be28 100644 --- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -340,11 +340,11 @@ struct JSRuntime : public js::MallocProvider js::ActiveThreadData> cooperatingContexts_; // Count of AutoProhibitActiveContextChange instances on the active context. - mozilla::Atomic activeContextChangeProhibited_; + js::ActiveThreadData activeContextChangeProhibited_; // Count of beginSingleThreadedExecution() calls that have occurred with no // matching endSingleThreadedExecution(). - mozilla::Atomic singleThreadedExecutionRequired_; + js::ActiveThreadData singleThreadedExecutionRequired_; // Whether some thread has called beginSingleThreadedExecution() and we are // in the associated callback (which may execute JS on other threads).