Catch more exceptions in dtors

Misc coverity reports
This commit is contained in:
moneromooo-monero 2018-10-02 08:39:47 +00:00
parent 83d8f03c23
commit e5108a294a
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
17 changed files with 43 additions and 1 deletions

View File

@ -147,7 +147,8 @@ namespace misc_utils
{}
~call_befor_die()
{
m_func();
try { m_func(); }
catch (...) { /* ignore */ }
}
};

View File

@ -51,11 +51,19 @@ threadpool::threadpool(unsigned int max_threads) : running(true), active(0) {
}
threadpool::~threadpool() {
try
{
const boost::unique_lock<boost::mutex> lock(mutex);
running = false;
has_work.notify_all();
}
catch (...)
{
// if the lock throws, we're just do it without a lock and hope,
// since the alternative is terminate
running = false;
has_work.notify_all();
}
for (size_t i = 0; i<threads.size(); i++) {
try { threads[i].join(); }
catch (...) { /* ignore */ }
@ -91,11 +99,13 @@ unsigned int threadpool::get_max_concurrency() const {
threadpool::waiter::~waiter()
{
try
{
boost::unique_lock<boost::mutex> lock(mt);
if (num)
MERROR("wait should have been called before waiter dtor - waiting now");
}
catch (...) { /* ignore */ }
try
{
wait(NULL);

View File

@ -35,6 +35,7 @@
#include <vector>
#include "warnings.h"
#include "misc_log_ex.h"
#include "crypto/crypto.h"
#include "crypto/hash.h"
#include "crypto-tests.h"
@ -59,6 +60,7 @@ bool operator !=(const key_derivation &a, const key_derivation &b) {
DISABLE_GCC_WARNING(maybe-uninitialized)
int main(int argc, char *argv[]) {
TRY_ENTRY();
fstream input;
string cmd;
size_t test = 0;
@ -266,4 +268,5 @@ error:
error = true;
}
return error ? 1 : 0;
CATCH_ENTRY_L0("main", 1);
}

View File

@ -68,7 +68,9 @@ int Base58Fuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
TRY_ENTRY();
Base58Fuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
CATCH_ENTRY_L0("main", 1);
}

View File

@ -61,6 +61,8 @@ int BlockFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
TRY_ENTRY();
BlockFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
CATCH_ENTRY_L0("main", 1);
}

View File

@ -65,6 +65,8 @@ int BulletproofFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
TRY_ENTRY();
BulletproofFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
CATCH_ENTRY_L0("main", 1);
}

View File

@ -95,7 +95,9 @@ int ColdOutputsFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
TRY_ENTRY();
ColdOutputsFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
CATCH_ENTRY_L0("main", 1);
}

View File

@ -97,6 +97,8 @@ int ColdTransactionFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
TRY_ENTRY();
ColdTransactionFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
CATCH_ENTRY_L0("main", 1);
}

View File

@ -92,7 +92,9 @@ int HTTPClientFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
TRY_ENTRY();
HTTPClientFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
CATCH_ENTRY_L0("main", 1);
}

View File

@ -341,7 +341,9 @@ int LevinFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
TRY_ENTRY();
LevinFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
CATCH_ENTRY_L0("main", 1);
}

View File

@ -70,7 +70,9 @@ int PortableStorageFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
TRY_ENTRY();
PortableStorageFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
CATCH_ENTRY_L0("main", 1);
}

View File

@ -70,7 +70,9 @@ int PortableStorageFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
TRY_ENTRY();
PortableStorageFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
CATCH_ENTRY_L0("main", 1);
}

View File

@ -68,7 +68,9 @@ int ParseURLFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
TRY_ENTRY();
ParseURLFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
CATCH_ENTRY_L0("main", 1);
}

View File

@ -92,6 +92,8 @@ int SignatureFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
TRY_ENTRY();
SignatureFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
CATCH_ENTRY_L0("main", 1);
}

View File

@ -61,6 +61,8 @@ int TransactionFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
TRY_ENTRY();
TransactionFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
CATCH_ENTRY_L0("main", 1);
}

View File

@ -628,6 +628,7 @@ TEST_F(net_load_test_clt, permament_open_and_close_and_connections_closed_by_ser
int main(int argc, char** argv)
{
TRY_ENTRY();
tools::on_startup();
epee::debug::get_set_enable_assert(true, false);
//set up logging options
@ -635,4 +636,5 @@ int main(int argc, char** argv)
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
CATCH_ENTRY_L0("main", 1);
}

View File

@ -215,6 +215,7 @@ namespace
int main(int argc, char** argv)
{
TRY_ENTRY();
tools::on_startup();
//set up logging options
mlog_configure(mlog_get_default_log_path("net_load_tests_srv.log"), true);
@ -233,4 +234,5 @@ int main(int argc, char** argv)
if (!tcp_server.run_server(thread_count, true))
return 2;
return 0;
CATCH_ENTRY_L0("main", 1);
}