Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random minor fixes #4459

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c57a65b
blockchain_blackball: fix shift range for 32 bit archs
moneromooo-monero Sep 27, 2018
02563bf
simplewallet: top level exception catcher to print nicer messages
moneromooo-monero Sep 27, 2018
d8b1ec8
unit_tests: use std::shared_ptr to shut coverity up about leaks
moneromooo-monero Sep 27, 2018
a085da3
unit_tests: add check for page size > 0 before dividing
moneromooo-monero Sep 27, 2018
7ece155
performance_test: fix bad last argument calling add_arg
moneromooo-monero Sep 27, 2018
5fdcda5
easylogging++: test for NULL before dereference
moneromooo-monero Sep 27, 2018
661439f
mlog: don't remove old logs if we failed to rename the current file
moneromooo-monero Sep 27, 2018
e67016d
blockchain_blackball: catch failure to commit db transaction
moneromooo-monero Sep 27, 2018
53df2de
db_lmdb: catch error in mdb_stat calls during migration
moneromooo-monero Sep 27, 2018
6e85542
gen_multisig: nice exit on unhandled exception
moneromooo-monero Sep 27, 2018
ea7f954
threadpool: do not propagate exceptions through the dtor
moneromooo-monero Sep 27, 2018
418a993
unit_tests: catch unhandled exceptions
moneromooo-monero Sep 27, 2018
1b0afee
wallet_rpc_server: exit cleanly on unhandled exceptions
moneromooo-monero Sep 27, 2018
0749a8b
db_lmdb: do not propagate exceptions in dtor
moneromooo-monero Sep 27, 2018
2e2139f
epee: do not propagate exception through dtor
moneromooo-monero Sep 27, 2018
fb6a363
miner: do not propagate exceptions through dtor
moneromooo-monero Sep 27, 2018
1eebb82
net_helper: do not propagate exceptions through dtor
moneromooo-monero Sep 27, 2018
a093092
levin_protocol_handler_async: do not propagate exception through dtor
moneromooo-monero Sep 27, 2018
3ebd05d
miner: restore stream flags after changing them
moneromooo-monero Sep 27, 2018
bcf3f6a
fuzz_tests: catch unhandled exceptions
moneromooo-monero Sep 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion contrib/epee/include/console_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ namespace epee

~async_stdin_reader()
{
stop();
try { stop(); }
catch (...) { /* ignore */ }
}

#ifdef HAVE_READLINE
Expand Down
6 changes: 6 additions & 0 deletions contrib/epee/include/net/levin_protocol_handler_async.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ class async_protocol_handler
}
virtual ~async_protocol_handler()
{
try
{

m_deletion_initiated = true;
if(m_connection_initialized)
{
Expand All @@ -288,6 +291,9 @@ class async_protocol_handler
CHECK_AND_ASSERT_MES_NO_RET(0 == boost::interprocess::ipcdetail::atomic_read32(&m_wait_count), "Failed to wait for operation completion. m_wait_count = " << m_wait_count);

MTRACE(m_connection_context << "~async_protocol_handler()");

}
catch (...) { /* ignore */ }
}

bool start_outer_call()
Expand Down
3 changes: 2 additions & 1 deletion contrib/epee/include/net/net_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ namespace net_utils
~blocked_mode_client()
{
//profile_tools::local_coast lc("~blocked_mode_client()", 3);
shutdown();
try { shutdown(); }
catch(...) { /* ignore */ }
}

inline
Expand Down
7 changes: 6 additions & 1 deletion contrib/epee/src/mlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ void mlog_configure(const std::string &filename_base, bool console, const std::s
el::Loggers::addFlag(el::LoggingFlag::StrictLogFileSizeCheck);
el::Helpers::installPreRollOutCallback([filename_base, max_log_files](const char *name, size_t){
std::string rname = generate_log_filename(filename_base.c_str());
rename(name, rname.c_str());
int ret = rename(name, rname.c_str());
if (ret < 0)
{
// can't log a failure, but don't do the file removal below
return;
}
if (max_log_files != 0)
{
std::vector<boost::filesystem::path> found_files;
Expand Down
4 changes: 2 additions & 2 deletions external/easylogging++/easylogging++.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1975,11 +1975,11 @@ void VRegistry::setCategories(const char* categories, bool clear) {
m_cached_allowed_categories.clear();
m_categoriesString.clear();
}
if (!categories)
return;
if (!m_categoriesString.empty())
m_categoriesString += ",";
m_categoriesString += categories;
if (!categories)
return;

bool isCat = true;
bool isLevel = false;
Expand Down
21 changes: 16 additions & 5 deletions src/blockchain_db/lmdb/db_lmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,10 @@ BlockchainLMDB::~BlockchainLMDB()

// batch transaction shouldn't be active at this point. If it is, consider it aborted.
if (m_batch_active)
batch_abort();
{
try { batch_abort(); }
catch (...) { /* ignore */ }
}
if (m_open)
close();
}
Expand Down Expand Up @@ -3579,7 +3582,9 @@ void BlockchainLMDB::migrate_0_1()
throw0(DB_ERROR(lmdb_error("Failed to open a cursor for block_heights: ", result).c_str()));
if (!i) {
MDB_stat ms;
mdb_stat(txn, m_block_heights, &ms);
result = mdb_stat(txn, m_block_heights, &ms);
if (result)
throw0(DB_ERROR(lmdb_error("Failed to query block_heights table: ", result).c_str()));
i = ms.ms_entries;
}
}
Expand Down Expand Up @@ -3682,7 +3687,9 @@ void BlockchainLMDB::migrate_0_1()
throw0(DB_ERROR(lmdb_error("Failed to open a cursor for block_timestamps: ", result).c_str()));
if (!i) {
MDB_stat ms;
mdb_stat(txn, m_block_info, &ms);
result = mdb_stat(txn, m_block_info, &ms);
if (result)
throw0(DB_ERROR(lmdb_error("Failed to query block_info table: ", result).c_str()));
i = ms.ms_entries;
}
}
Expand Down Expand Up @@ -3802,7 +3809,9 @@ void BlockchainLMDB::migrate_0_1()
throw0(DB_ERROR(lmdb_error("Failed to open a cursor for spent_keys: ", result).c_str()));
if (!i) {
MDB_stat ms;
mdb_stat(txn, m_hf_versions, &ms);
result = mdb_stat(txn, m_hf_versions, &ms);
if (result)
throw0(DB_ERROR(lmdb_error("Failed to query hf_versions table: ", result).c_str()));
i = ms.ms_entries;
}
}
Expand Down Expand Up @@ -3957,7 +3966,9 @@ void BlockchainLMDB::migrate_0_1()
throw0(DB_ERROR(lmdb_error("Failed to open a cursor for txs: ", result).c_str()));
if (!i) {
MDB_stat ms;
mdb_stat(txn, m_txs, &ms);
result = mdb_stat(txn, m_txs, &ms);
if (result)
throw0(DB_ERROR(lmdb_error("Failed to query txs table: ", result).c_str()));
i = ms.ms_entries;
if (i) {
MDB_val_set(pk, "txblk");
Expand Down
8 changes: 5 additions & 3 deletions src/blockchain_utilities/blockchain_blackball.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,8 @@ static bool for_all_transactions(const std::string &filename, uint64_t &start_id
}

mdb_cursor_close(cur);
mdb_txn_commit(txn);
dbr = mdb_txn_commit(txn);
if (dbr) throw std::runtime_error("Failed to commit db transaction: " + std::string(mdb_strerror(dbr)));
tx_active = false;
mdb_dbi_close(env, dbi);
mdb_env_close(env);
Expand Down Expand Up @@ -471,7 +472,8 @@ static uint64_t find_first_diverging_transaction(const std::string &first_filena
for (int i = 0; i < 2; ++i)
{
mdb_cursor_close(cur[i]);
mdb_txn_commit(txn[i]);
dbr = mdb_txn_commit(txn[i]);
if (dbr) throw std::runtime_error("Failed to query transaction: " + std::string(mdb_strerror(dbr)));
tx_active[i] = false;
mdb_dbi_close(env[i], dbi[i]);
mdb_env_close(env[i]);
Expand Down Expand Up @@ -675,7 +677,7 @@ static uint64_t get_ring_subset_instances(MDB_txn *txn, uint64_t amount, const s
uint64_t extra = 0;
std::vector<uint64_t> subset;
subset.reserve(ring.size());
for (uint64_t mask = 1; mask < (1u << ring.size()) - 1; ++mask)
for (uint64_t mask = 1; mask < (((uint64_t)1) << ring.size()) - 1; ++mask)
{
subset.resize(0);
for (size_t i = 0; i < ring.size(); ++i)
Expand Down
3 changes: 2 additions & 1 deletion src/common/threadpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ threadpool::~threadpool() {
has_work.notify_all();
}
for (size_t i = 0; i<threads.size(); i++) {
threads[i].join();
try { threads[i].join(); }
catch (...) { /* ignore */ }
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/cryptonote_basic/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ namespace cryptonote
//-----------------------------------------------------------------------------------------------------
miner::~miner()
{
stop();
try { stop(); }
catch (...) { /* ignore */ }
}
//-----------------------------------------------------------------------------------------------------
bool miner::set_block_template(const block& bl, const difficulty_type& di, uint64_t height)
Expand Down Expand Up @@ -198,8 +199,9 @@ namespace cryptonote
{
uint64_t total_hr = std::accumulate(m_last_hash_rates.begin(), m_last_hash_rates.end(), 0);
float hr = static_cast<float>(total_hr)/static_cast<float>(m_last_hash_rates.size());
const auto flags = std::cout.flags();
const auto precision = std::cout.precision();
std::cout << "hashrate: " << std::setprecision(4) << std::fixed << hr << precision << ENDL;
std::cout << "hashrate: " << std::setprecision(4) << std::fixed << hr << flags << precision << ENDL;
}
}
m_last_hr_merge_time = misc_utils::get_tick_count();
Expand Down
4 changes: 3 additions & 1 deletion src/gen_multisig/gen_multisig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ static bool generate_multisig(uint32_t threshold, uint32_t total, const std::str

int main(int argc, char* argv[])
{
TRY_ENTRY();

po::options_description desc_params(wallet_args::tr("Wallet options"));
command_line::add_arg(desc_params, arg_filename_base);
command_line::add_arg(desc_params, arg_scheme);
Expand Down Expand Up @@ -254,5 +256,5 @@ int main(int argc, char* argv[])
return 1;

return 0;
//CATCH_ENTRY_L0("main", 1);
CATCH_ENTRY_L0("main", 1);
}
4 changes: 3 additions & 1 deletion src/simplewallet/simplewallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8072,6 +8072,8 @@ void simple_wallet::commit_or_save(std::vector<tools::wallet2::pending_tx>& ptx_
//----------------------------------------------------------------------------------------------------
int main(int argc, char* argv[])
{
TRY_ENTRY();

#ifdef WIN32
// Activate UTF-8 support for Boost filesystem classes on Windows
std::locale::global(boost::locale::generator().generate(""));
Expand Down Expand Up @@ -8166,5 +8168,5 @@ int main(int argc, char* argv[])
w.deinit();
}
return 0;
//CATCH_ENTRY_L0("main", 1);
CATCH_ENTRY_L0("main", 1);
}
3 changes: 3 additions & 0 deletions src/wallet/wallet_rpc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3457,6 +3457,8 @@ class t_executor final
std::string const t_executor::NAME = "Wallet RPC Daemon";

int main(int argc, char** argv) {
TRY_ENTRY();

namespace po = boost::program_options;

const auto arg_wallet_file = wallet_args::arg_wallet_file();
Expand Down Expand Up @@ -3500,4 +3502,5 @@ int main(int argc, char** argv) {
}

return daemonizer::daemonize(argc, const_cast<const char**>(argv), t_executor{}, *vm) ? 0 : 1;
CATCH_ENTRY_L0("main", 1);
}
4 changes: 4 additions & 0 deletions tests/fuzz/fuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ static int __AFL_LOOP(int)

int run_fuzzer(int argc, const char **argv, Fuzzer &fuzzer)
{
TRY_ENTRY();

if (argc < 2)
{
std::cout << "usage: " << argv[0] << " " << "<filename>" << std::endl;
Expand All @@ -69,4 +71,6 @@ int run_fuzzer(int argc, const char **argv, Fuzzer &fuzzer)
}

return 0;

CATCH_ENTRY_L0("run_fuzzer", 1);
}
8 changes: 4 additions & 4 deletions tests/performance_tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ int main(int argc, char** argv)
const command_line::arg_descriptor<bool> arg_verbose = { "verbose", "Verbose output", false };
const command_line::arg_descriptor<bool> arg_stats = { "stats", "Including statistics (min/median)", false };
const command_line::arg_descriptor<unsigned> arg_loop_multiplier = { "loop-multiplier", "Run for that many times more loops", 1 };
command_line::add_arg(desc_options, arg_filter, "");
command_line::add_arg(desc_options, arg_verbose, "");
command_line::add_arg(desc_options, arg_stats, "");
command_line::add_arg(desc_options, arg_loop_multiplier, "");
command_line::add_arg(desc_options, arg_filter);
command_line::add_arg(desc_options, arg_verbose);
command_line::add_arg(desc_options, arg_stats);
command_line::add_arg(desc_options, arg_loop_multiplier);

po::variables_map vm;
bool r = command_line::handle_error_helper(desc_options, [&]()
Expand Down
4 changes: 4 additions & 0 deletions tests/unit_tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ namespace cryptonote { template class t_cryptonote_protocol_handler<cryptonote::

int main(int argc, char** argv)
{
TRY_ENTRY();

tools::on_startup();
epee::string_tools::set_module_name_and_folder(argv[0]);
mlog_configure(mlog_get_default_log_path("unit_tests.log"), true);
Expand All @@ -76,5 +78,7 @@ int main(int argc, char** argv)

unit_test::data_dir = command_line::get_arg(vm, arg_data_dir);

CATCH_ENTRY_L0("main", 1);

return RUN_ALL_TESTS();
}
Loading