From 760ecf2ac812f4574dd851aa7ac72c3ff1230482 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Wed, 12 Feb 2020 13:57:04 +0000 Subject: [PATCH 1/3] console_handler: do not let exception past the dor Coverity 208373 --- contrib/epee/include/console_handler.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/contrib/epee/include/console_handler.h b/contrib/epee/include/console_handler.h index 1b716fca4..a7788aeb8 100644 --- a/contrib/epee/include/console_handler.h +++ b/contrib/epee/include/console_handler.h @@ -606,11 +606,15 @@ eof: async_console_handler m_console_handler; public: ~console_handlers_binder() { - stop_handling(); - if (m_console_thread.get() != nullptr) + try { - m_console_thread->join(); + stop_handling(); + if (m_console_thread.get() != nullptr) + { + m_console_thread->join(); + } } + catch (const std::exception &e) { /* ignore */ } } bool start_handling(std::function prompt, const std::string& usage_string = "", std::function exit_handler = NULL) From 09c8111c53a5adf3ca0e3d28d2b2652cc794efdb Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Wed, 12 Feb 2020 14:00:16 +0000 Subject: [PATCH 2/3] threadpool: lock mutex in create In some contrived case, it might theoretically be the case that destroy is called from another thread, which would modify the threads array from two threads. Coverity 208372 --- src/common/threadpool.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/threadpool.cpp b/src/common/threadpool.cpp index 18204eeee..753bf238c 100644 --- a/src/common/threadpool.cpp +++ b/src/common/threadpool.cpp @@ -71,6 +71,7 @@ void threadpool::recycle() { } void threadpool::create(unsigned int max_threads) { + const boost::unique_lock lock(mutex); boost::thread::attributes attrs; attrs.set_stack_size(THREAD_STACK_SIZE); max = max_threads ? max_threads : tools::get_max_concurrency(); From e3779775d77a986d90f47708570bc1d6de26d5e7 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Wed, 12 Feb 2020 14:05:21 +0000 Subject: [PATCH 3/3] tx_pool: catch theoretical error in get_block_reward Coverity 196626 --- src/cryptonote_core/tx_pool.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index 1bc475879..13320e69f 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -1268,7 +1268,11 @@ namespace cryptonote fee = 0; //baseline empty block - get_block_reward(median_weight, total_weight, already_generated_coins, best_coinbase, version); + if (!get_block_reward(median_weight, total_weight, already_generated_coins, best_coinbase, version)) + { + MERROR("Failed to get block reward for empty block"); + return false; + } size_t max_total_weight_pre_v5 = (130 * median_weight) / 100 - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE;