diff --git a/runtime/dart_vm.cc b/runtime/dart_vm.cc index c9ee5f920035d..b263914538217 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; }