Skip to content

Commit

Permalink
Assert that all VM launches in the process have the same opinion on w…
Browse files Browse the repository at this point in the history
…hether the VM should be leaked in the process. (#8622)

There is a possibility for a VM launch to not have a requisite shutdown if a previous launch asked to leak the VM instance in the process. Embedders have to ensure (via their Embedding APIs) that all instances of VM launch use consistent settings.
  • Loading branch information
chinmaygarde committed Apr 18, 2019
1 parent 72c84c2 commit 876c4c3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions runtime/dart_vm_lifecycle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ DartVMRef DartVMRef::Create(Settings settings,
fml::RefPtr<DartSnapshot> shared_snapshot) {
std::lock_guard<std::mutex> lifecycle_lock(gVMMutex);

if (!settings.leak_vm) {
FML_CHECK(!gVMLeak)
<< "Launch settings indicated that the VM should shut down in the "
"process when done but a previous launch asked the VM to leak in "
"the same process. For proper VM shutdown, all VM launches must "
"indicate that they should shut down when done.";
}

// If there is already a running VM in the process, grab a strong reference to
// it.
if (auto vm = gVM.lock()) {
Expand Down

0 comments on commit 876c4c3

Please sign in to comment.