Index: Source/bindings/v8/WorkerScriptController.cpp |
diff --git a/Source/bindings/v8/WorkerScriptController.cpp b/Source/bindings/v8/WorkerScriptController.cpp |
index 947aa27d062537722080e3ab0931619a00f899db..8b5c32ec7b1949f1fe3eaaa1e4ba2c17d7568190 100644 |
--- a/Source/bindings/v8/WorkerScriptController.cpp |
+++ b/Source/bindings/v8/WorkerScriptController.cpp |
@@ -70,6 +70,16 @@ WorkerScriptController::WorkerScriptController(WorkerGlobalScope& workerGlobalSc |
V8PerIsolateData::ensureInitialized(m_isolate); |
m_world = DOMWrapperWorld::create(WorkerWorldId); |
m_interruptor = adoptPtr(new V8IsolateInterruptor(m_isolate)); |
+ |
+ // FIXME: Calling v8::Context::New in ensureDomInJsContext() later may |
+ // fail in certain cases and lead to a crash. |
+ // Since the main thread may call scheduleExecutionTermination at arbitrary |
+ // timing, calling v8::Context::New in the worker thread may fail and |
+ // result in a crash. |
+ // We need these statements here to prevent that. |
+ v8::HandleScope handleScope(m_isolate); |
+ V8PerIsolateData::from(m_isolate)->ensureDomInJSContext(); |
+ |
ThreadState::current()->addInterruptor(m_interruptor.get()); |
} |