From c5287237ee9df53e754cbd7b10555d45ca5cc3b8 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Wed, 15 Feb 2017 15:35:41 -0800 Subject: [PATCH] fix(library/vm): race condition in the profiler initialization code --- src/library/vm/vm.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/library/vm/vm.cpp b/src/library/vm/vm.cpp index b2347f6a7c..b043013495 100644 --- a/src/library/vm/vm.cpp +++ b/src/library/vm/vm.cpp @@ -3290,8 +3290,6 @@ vm_state::profiler::profiler(vm_state & s, options const & opts): m_freq_ms(get_profiler_freq(opts)), m_thread_ptr(get_profiler(opts) ? new interruptible_thread([&]() { - lean_assert(!m_state.m_profiling); - m_state.m_profiling = true; chrono::milliseconds d(m_freq_ms); bool first = true; auto start = chrono::steady_clock::now(); @@ -3320,7 +3318,8 @@ vm_state::profiler::profiler(vm_state & s, options const & opts): m_freq_ms(0), m_thread_ptr(nullptr) #endif - { +{ + m_state.m_profiling = get_profiler(opts); } void vm_state::profiler::stop() {