From 17a8ec10b3ca3c4ac0f3dca26c4106213a999584 Mon Sep 17 00:00:00 2001 From: Daniel Mapleson Date: Fri, 7 Apr 2017 15:08:35 +0100 Subject: [PATCH] Fixed a bug which was causing a seg fault when using the comp tool with bin sizes larger than the default value. --- configure.ac | 2 +- doc/source/conf.py | 4 ++-- lib/include/kat/comp_counters.hpp | 4 ++++ lib/include/kat/sparse_matrix.hpp | 2 +- lib/src/comp_counters.cc | 4 ++++ src/comp.cc | 3 +-- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 36f4416b..8e70640d 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ # Autoconf initialistion. Sets package name version and contact details AC_PREREQ([2.68]) -AC_INIT([kat],[2.3.2],[https://github.com/TGAC/KAT/issues],[kat],[https://github.com/TGAC/KAT]) +AC_INIT([kat],[2.3.3],[https://github.com/TGAC/KAT/issues],[kat],[https://github.com/TGAC/KAT]) AC_CONFIG_SRCDIR([src/kat.cc]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/doc/source/conf.py b/doc/source/conf.py index 0816bdf2..a7d5e020 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -52,9 +52,9 @@ # built documents. # # The short X.Y version. -version = '2.3.2' +version = '2.3.3' # The full version, including alpha/beta/rc tags. -release = '2.3.2' +release = '2.3.3' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/lib/include/kat/comp_counters.hpp b/lib/include/kat/comp_counters.hpp index e482a88a..5ce341d4 100644 --- a/lib/include/kat/comp_counters.hpp +++ b/lib/include/kat/comp_counters.hpp @@ -57,6 +57,8 @@ class CompCounters { path hash3_path; CompCounters(); + + CompCounters(const size_t _dm_size); CompCounters(const path& _hash1_path, const path& _hash2_path, const path& _hash3_path, const size_t _dm_size); @@ -92,6 +94,8 @@ class ThreadedCompCounters { public: ThreadedCompCounters(); + + ThreadedCompCounters(const size_t _dm_size); ThreadedCompCounters(const path& _hash1_path, const path& _hash2_path, const path& _hash3_path, const size_t _dm_size); diff --git a/lib/include/kat/sparse_matrix.hpp b/lib/include/kat/sparse_matrix.hpp index 7e9423c0..fed458a9 100644 --- a/lib/include/kat/sparse_matrix.hpp +++ b/lib/include/kat/sparse_matrix.hpp @@ -323,7 +323,7 @@ class ThreadedSparseMatrix { } const SM64& mergeThreadedMatricies() { - // Merge matrix + // Merge matrix for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { for (int k = 0; k < threads; k++) { diff --git a/lib/src/comp_counters.cc b/lib/src/comp_counters.cc index a219fb5d..37ab8ffa 100644 --- a/lib/src/comp_counters.cc +++ b/lib/src/comp_counters.cc @@ -39,6 +39,8 @@ using kat::DistanceMetric; kat::CompCounters::CompCounters() : CompCounters("", "", "", DEFAULT_NB_BINS) {} +kat::CompCounters::CompCounters(const size_t _dm_size) : CompCounters("", "", "", _dm_size) {} + kat::CompCounters::CompCounters(const path& _hash1_path, const path& _hash2_path, const path& _hash3_path, const size_t _dm_size) : hash1_path(_hash1_path), hash2_path(_hash2_path), hash3_path(_hash3_path) { @@ -208,6 +210,8 @@ void kat::CompCounters::printCounts(ostream &out) { kat::ThreadedCompCounters::ThreadedCompCounters() : ThreadedCompCounters("", "", "", DEFAULT_NB_BINS) {} +kat::ThreadedCompCounters::ThreadedCompCounters(const size_t _dm_size) : ThreadedCompCounters("", "", "", _dm_size) {} + kat::ThreadedCompCounters::ThreadedCompCounters(const path& _hash1_path, const path& _hash2_path, const path& _hash3_path, const size_t _dm_size) { final_matrix = CompCounters(_hash1_path, _hash2_path, _hash3_path, _dm_size); } diff --git a/src/comp.cc b/src/comp.cc index 8664fe6f..41813776 100644 --- a/src/comp.cc +++ b/src/comp.cc @@ -253,7 +253,6 @@ void kat::Comp::merge() { cout << "Merging results ..."; cout.flush(); - // Merge results from the threads main_matrix.mergeThreadedMatricies(); if (doThirdHash()) { @@ -390,7 +389,7 @@ void kat::Comp::compare() { void kat::Comp::compareSlice(int th_id) { - shared_ptr cc = make_shared(); + shared_ptr cc = make_shared(std::min(this->d1Bins, this->d2Bins)); // Setup iterator for this thread's chunk of hash1 LargeHashArray::eager_iterator hash1Iterator = input[0].hash->eager_slice(th_id, threads);