From 9b1c3a4c5e0151d3c967b1734ea52b3298a85e69 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Tue, 17 Jul 2018 14:20:08 +0300 Subject: [PATCH] [android] Fix possibly race on undefined behavior `runnable->iter = runnables.end()` assumes that `::end()` is a `static` or `constxpr` and thread-safe. This is likely to be true for most of the implementations. That said we cannot rely on undefined behavior and we should assume the worse case scenario. --- platform/android/src/run_loop.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/android/src/run_loop.cpp b/platform/android/src/run_loop.cpp index f655f13ea8a..b55f2be1905 100644 --- a/platform/android/src/run_loop.cpp +++ b/platform/android/src/run_loop.cpp @@ -167,6 +167,7 @@ void RunLoop::Impl::removeRunnable(Runnable* runnable) { } void RunLoop::Impl::initRunnable(Runnable* runnable) { + std::lock_guard lock(mtx); runnable->iter = runnables.end(); }