From 836669d276c1efda3f2805b17f0488a12bf3e85b Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 29 Oct 2016 13:31:53 +0100 Subject: [PATCH 1/3] ringct: always shutdown the boost io service Even if no worker threads were started, it needs shutting down or it will cause an invalid access in the io service thread --- src/ringct/rctSigs.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ringct/rctSigs.cpp b/src/ringct/rctSigs.cpp index f7ea3729d..86d98fca2 100644 --- a/src/ringct/rctSigs.cpp +++ b/src/ringct/rctSigs.cpp @@ -772,7 +772,7 @@ namespace rct { threads = std::min(threads, rv.outPk.size()); for (size_t i = 0; i < threads; ++i) threadpool.create_thread(boost::bind(&boost::asio::io_service::run, &ioservice)); - bool ioservice_active = threads > 1; + bool ioservice_active = true; std::deque results(rv.outPk.size(), false); epee::misc_utils::auto_scope_leave_caller ioservice_killer = epee::misc_utils::create_scope_leave_handler([&]() { KILL_IOSERVICE(); }); @@ -838,7 +838,7 @@ namespace rct { threads = std::min(threads, rv.outPk.size()); for (size_t i = 0; i < threads; ++i) threadpool.create_thread(boost::bind(&boost::asio::io_service::run, &ioservice)); - bool ioservice_active = threads > 1; + bool ioservice_active = true; std::deque results(rv.outPk.size(), false); epee::misc_utils::auto_scope_leave_caller ioservice_killer = epee::misc_utils::create_scope_leave_handler([&]() { KILL_IOSERVICE(); }); @@ -880,7 +880,7 @@ namespace rct { threads = std::min(threads, rv.mixRing.size()); for (size_t i = 0; i < threads; ++i) threadpool.create_thread(boost::bind(&boost::asio::io_service::run, &ioservice)); - bool ioservice_active = threads > 1; + bool ioservice_active = true; std::deque results(rv.mixRing.size(), false); epee::misc_utils::auto_scope_leave_caller ioservice_killer = epee::misc_utils::create_scope_leave_handler([&]() { KILL_IOSERVICE(); }); From ffd8c41f36dc38db96bef169dbe2bfe20652d8f8 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 29 Oct 2016 13:33:08 +0100 Subject: [PATCH 2/3] ringct: check the size of amount_keys is the same as destinations --- src/ringct/rctSigs.cpp | 2 ++ tests/unit_tests/ringct.cpp | 5 +++-- tests/unit_tests/serialization.cpp | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ringct/rctSigs.cpp b/src/ringct/rctSigs.cpp index 86d98fca2..19e9d291e 100644 --- a/src/ringct/rctSigs.cpp +++ b/src/ringct/rctSigs.cpp @@ -610,6 +610,7 @@ namespace rct { // Thus the amounts vector will be "one" longer than the destinations vectort rctSig genRct(const key &message, const ctkeyV & inSk, const keyV & destinations, const vector & amounts, const ctkeyM &mixRing, const keyV &amount_keys, unsigned int index, ctkeyV &outSk) { CHECK_AND_ASSERT_THROW_MES(amounts.size() == destinations.size() || amounts.size() == destinations.size() + 1, "Different number of amounts/destinations"); + CHECK_AND_ASSERT_THROW_MES(amount_keys.size() == destinations.size(), "Different number of amount_keys/destinations"); CHECK_AND_ASSERT_THROW_MES(index < mixRing.size(), "Bad index into mixRing"); for (size_t n = 0; n < mixRing.size(); ++n) { CHECK_AND_ASSERT_THROW_MES(mixRing[n].size() == inSk.size(), "Bad mixRing size"); @@ -671,6 +672,7 @@ namespace rct { CHECK_AND_ASSERT_THROW_MES(inamounts.size() > 0, "Empty inamounts"); CHECK_AND_ASSERT_THROW_MES(inamounts.size() == inSk.size(), "Different number of inamounts/inSk"); CHECK_AND_ASSERT_THROW_MES(outamounts.size() == destinations.size(), "Different number of amounts/destinations"); + CHECK_AND_ASSERT_THROW_MES(amount_keys.size() == destinations.size(), "Different number of amount_keys/destinations"); CHECK_AND_ASSERT_THROW_MES(index.size() == inSk.size(), "Different number of index/inSk"); CHECK_AND_ASSERT_THROW_MES(mixRing.size() == inSk.size(), "Different number of mixRing/inSk"); for (size_t n = 0; n < mixRing.size(); ++n) { diff --git a/tests/unit_tests/ringct.cpp b/tests/unit_tests/ringct.cpp index 224e32e61..1abf2511d 100644 --- a/tests/unit_tests/ringct.cpp +++ b/tests/unit_tests/ringct.cpp @@ -246,7 +246,6 @@ TEST(ringct, range_proofs_with_fee) //add txn fee for 1 //has no corresponding destination.. amounts.push_back(1); - amount_keys.push_back(hash_to_scalar(zero())); //add output for 12500 amounts.push_back(12500); @@ -356,10 +355,12 @@ static rct::rctSig make_sample_rct_sig(int n_inputs, const uint64_t input_amount for (int n = 0; n < n_outputs; ++n) { amounts.push_back(output_amounts[n]); - amount_keys.push_back(rct::hash_to_scalar(rct::zero())); skpkGen(Sk, Pk); if (n < n_outputs - 1 || !last_is_fee) + { destinations.push_back(Pk); + amount_keys.push_back(rct::hash_to_scalar(rct::zero())); + } } return genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, 3);; diff --git a/tests/unit_tests/serialization.cpp b/tests/unit_tests/serialization.cpp index f51f9ec67..dc7f7cb06 100644 --- a/tests/unit_tests/serialization.cpp +++ b/tests/unit_tests/serialization.cpp @@ -559,6 +559,7 @@ TEST(Serialization, serializes_ringct_types) rct::keyV amount_keys; //add output 500 amounts.push_back(500); + amount_keys.push_back(rct::hash_to_scalar(rct::zero())); rct::keyV destinations; rct::key Sk, Pk; rct::skpkGen(Sk, Pk); From 48b57d813c88b3f64ab5cefd22bfd11defc02a92 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 29 Oct 2016 13:34:24 +0100 Subject: [PATCH 3/3] monero.supp: valgrind suppressions file Seeded with a spurious problem when inspecting stack trace --- contrib/valgrind/monero.supp | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 contrib/valgrind/monero.supp diff --git a/contrib/valgrind/monero.supp b/contrib/valgrind/monero.supp new file mode 100644 index 000000000..1c400076e --- /dev/null +++ b/contrib/valgrind/monero.supp @@ -0,0 +1,10 @@ +{ + libunwind causes spurious report + Memcheck:Param + msync(start) + ... + obj:/usr/lib64/libunwind.so.* + ... + fun:_ULx86_64_step + ... +}