From 546546a69c4627946858519ac90e0b10e8631bc0 Mon Sep 17 00:00:00 2001 From: Pttn <28868425+Pttn@users.noreply.github.com> Date: Fri, 29 Oct 2021 04:28:45 +0200 Subject: [PATCH] Proper Deletes This should fix the Restart Crash in Windows when the Difficulty varies, which was particularly critical. This fixes all Valgrind Errors for rieMinerL I think, and possible other very subtle bugs, though there are still Errors in the code with optimizations... Signed-off-by: Pttn <28868425+Pttn@users.noreply.github.com> --- Miner.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Miner.cpp b/Miner.cpp index a8c98b2..2ddd856 100644 --- a/Miner.cpp +++ b/Miner.cpp @@ -440,12 +440,16 @@ void Miner::clear() { std::cout << "Clearing miner's data..." << std::endl; _inited = false; for (auto &sieve : _sieves) { - delete sieve.factorsTable; - delete sieve.factorsToEliminate; + delete[] sieve.factorsTable; +#ifndef LIGHT + delete[] reinterpret_cast<__m256i*>(sieve.factorsToEliminate); +#else + delete[] sieve.factorsToEliminate; +#endif for (uint64_t j(0) ; j < _parameters.sieveIterations ; j++) - delete sieve.additionalFactorsToEliminate[j]; - delete sieve.additionalFactorsToEliminate; - delete sieve.additionalFactorsToEliminateCounts; + delete[] sieve.additionalFactorsToEliminate[j]; + delete[] sieve.additionalFactorsToEliminate; + delete[] sieve.additionalFactorsToEliminateCounts; } _sieves.clear(); _primes32.clear(); @@ -1177,11 +1181,11 @@ void Miner::_doTasks(const uint16_t id) { // Worker Threads run here until the m } // Thread clean up. for (int i(0) ; i < _parameters.sieveWorkers ; i++) { - delete factorsCacheCounts[i]; - delete factorsCache[i]; + delete[] factorsCacheCounts[i]; + delete[] factorsCache[i]; } - delete factorsCacheCounts; - delete factorsCache; + delete[] factorsCacheCounts; + delete[] factorsCache; } void Miner::_manageTasks() { @@ -1329,6 +1333,7 @@ void Miner::_suggestLessMemoryIntensiveOptions(const uint64_t suggestedPrimeTabl std::cout << "Try to use the following options in the " << confPath << " configuration file and retry:" << std::endl; std::cout << "PrimeTableLimit = " << suggestedPrimeTableLimit << std::endl; std::cout << "SieveWorkers = " << suggestedSieveWorkers << std::endl; + waitForUser(); } bool Miner::hasAcceptedPatterns(const std::vector> &acceptedPatterns) const {