diff --git a/runtime/dart_vm.cc b/runtime/dart_vm.cc index c9ee5f920035d089e378e90d9682671272dacf91..b263914538217b3a53a07723b1198ccf665ea47e 100644 --- a/runtime/dart_vm.cc +++ b/runtime/dart_vm.cc @@ -257,6 +257,7 @@ fml::RefPtr DartVM::ForProcess(Settings settings) { } static std::once_flag gVMInitialization; +static std::mutex gVMMutex; static fml::RefPtr gVM; fml::RefPtr DartVM::ForProcess( @@ -264,6 +265,7 @@ fml::RefPtr DartVM::ForProcess( fml::RefPtr vm_snapshot, fml::RefPtr isolate_snapshot, fml::RefPtr shared_snapshot) { + std::lock_guard lock(gVMMutex); std::call_once(gVMInitialization, [settings, // vm_snapshot, // isolate_snapshot, // @@ -296,6 +298,7 @@ fml::RefPtr DartVM::ForProcess( } fml::RefPtr DartVM::ForProcessIfInitialized() { + std::lock_guard lock(gVMMutex); return gVM; }