Skip to content

Commit 9bbccc7

Browse files
committed
Ensure to release the VM list mutex before destroying the environment
1 parent a606e6e commit 9bbccc7

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

vm/boostenv/main/boostenv.hh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,15 @@ void BoostEnvironment::killVM(VMIdentifier identifier, nativeint exitCode,
174174
void BoostEnvironment::removeTerminatedVM(VMIdentifier identifier,
175175
nativeint exitCode,
176176
boost::asio::io_service::work* work) {
177-
boost::lock_guard<boost::mutex> lock(_vmsMutex);
178-
179-
// Warning: the BoostVM is calling its own destructor with remove_if().
180-
// We also need VirtualMachine destructor to do its cleanup before dying.
181-
_vms.remove_if([=] (const BoostVM& vm) {
182-
return vm.identifier == identifier;
183-
});
177+
{
178+
boost::lock_guard<boost::mutex> lock(_vmsMutex);
179+
180+
// Warning: the BoostVM is calling its own destructor with remove_if().
181+
// We also need VirtualMachine destructor to do its cleanup before dying.
182+
_vms.remove_if([=] (const BoostVM& vm) {
183+
return vm.identifier == identifier;
184+
});
185+
}
184186

185187
if (identifier == InitialVMIdentifier) // only the exitCode of the initial VM is considered
186188
_exitCode = exitCode;

0 commit comments

Comments
 (0)