Merge "ART: Let JIT tasks finish under sanitization"
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 1dfb0f6..ae474da 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -20,6 +20,7 @@
#include "art_method-inl.h"
#include "base/enums.h"
+#include "base/memory_tool.h"
#include "debugger.h"
#include "entrypoints/runtime_asm_entrypoints.h"
#include "interpreter/interpreter.h"
@@ -308,20 +309,23 @@
Thread* self = Thread::Current();
DCHECK(Runtime::Current()->IsShuttingDown(self));
if (thread_pool_ != nullptr) {
- ThreadPool* cache = nullptr;
+ std::unique_ptr<ThreadPool> pool;
{
ScopedSuspendAll ssa(__FUNCTION__);
// Clear thread_pool_ field while the threads are suspended.
// A mutator in the 'AddSamples' method will check against it.
- cache = thread_pool_.release();
+ pool = std::move(thread_pool_);
}
- cache->StopWorkers(self);
- cache->RemoveAllTasks(self);
+
+ // When running sanitized, let all tasks finish to not leak. Otherwise just clear the queue.
+ if (!RUNNING_ON_MEMORY_TOOL) {
+ pool->StopWorkers(self);
+ pool->RemoveAllTasks(self);
+ }
// We could just suspend all threads, but we know those threads
// will finish in a short period, so it's not worth adding a suspend logic
// here. Besides, this is only done for shutdown.
- cache->Wait(self, false, false);
- delete cache;
+ pool->Wait(self, false, false);
}
}