[Orc] Fix the SharedMemoryMapper dtor
authorAlexandre Ganea <alex_toresh@yahoo.fr>
Fri, 30 Sep 2022 12:17:14 +0000 (08:17 -0400)
committerAlexandre Ganea <alex_toresh@yahoo.fr>
Wed, 5 Oct 2022 16:16:54 +0000 (12:16 -0400)
As briefly discussed on https://reviews.llvm.org/rG1134d3a03facccd75efc5385ba46918bef94fcb6, fix the unintended copy while iterating on Reservations and add a mutex guard, to be symmetric with other usages of Reservations.

Differential revision: https://reviews.llvm.org/D134212

llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp

index ecdf773..bb4568b 100644 (file)
@@ -412,6 +412,7 @@ void SharedMemoryMapper::release(ArrayRef<ExecutorAddr> Bases,
 }
 
 SharedMemoryMapper::~SharedMemoryMapper() {
+  std::lock_guard<std::mutex> Lock(Mutex);
   for (const auto &R : Reservations) {
 
 #if defined(LLVM_ON_UNIX) && !defined(__ANDROID__)