Skip to content

Commit

Permalink
Merge pull request #3563 from nanocurrency/sanitizer_fixes
Browse files Browse the repository at this point in the history
Fix a couple issues found with TSAN and add a suppression for Crypto++
  • Loading branch information
clemahieu authored Nov 22, 2021
2 parents 5fbe75e + 5d369dd commit cb87f07
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
13 changes: 6 additions & 7 deletions nano/core_test/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1536,19 +1536,18 @@ TEST (frontier_req, confirmed_frontier)
{
nano::system system (1);
auto node1 = system.nodes[0];
nano::raw_key priv_key;
nano::keypair key_before_genesis;
// Public key before genesis in accounts table
while (nano::pub_key (priv_key).number () >= nano::dev::genesis_key.pub.number ())
while (key_before_genesis.pub.number () >= nano::dev::genesis_key.pub.number ())
{
priv_key = nano::keypair ().prv;
key_before_genesis = nano::keypair ();
}
nano::keypair key_before_genesis (priv_key.to_string ());
nano::keypair key_after_genesis;
// Public key after genesis in accounts table
while (nano::pub_key (priv_key).number () <= nano::dev::genesis_key.pub.number ())
while (key_after_genesis.pub.number () <= nano::dev::genesis_key.pub.number ())
{
priv_key = nano::keypair ().prv;
key_after_genesis = nano::keypair ();
}
nano::keypair key_after_genesis (priv_key.to_string ());
nano::state_block_builder builder;

auto send1 = builder
Expand Down
19 changes: 19 additions & 0 deletions nano/core_test/uint256_union.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include <nano/crypto_lib/random_pool.hpp>
#include <nano/secure/common.hpp>
#include <nano/test_common/testutil.hpp>

#include <gtest/gtest.h>

#include <thread>

namespace
{
template <typename Union, typename Bound>
Expand Down Expand Up @@ -567,3 +570,19 @@ void check_operator_greater_than (Num lhs, Num rhs)
ASSERT_FALSE (rhs > rhs);
}
}

TEST (random_pool, multithreading)
{
std::vector<std::thread> threads;
for (auto i = 0; i < 100; ++i)
{
threads.emplace_back ([] () {
nano::uint256_union number;
nano::random_pool::generate_block (number.bytes.data (), number.bytes.size ());
});
}
for (auto & i : threads)
{
i.join ();
}
}
2 changes: 2 additions & 0 deletions tsan_suppressions
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
race:mdb.c
race:rocksdb
race:Rijndael::Base::FillEncTable
race:Rijndael::Base::FillDecTable

0 comments on commit cb87f07

Please sign in to comment.