Skip to content

Commit 546546a

Browse files
committed
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>
1 parent 565db1a commit 546546a

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

Miner.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,16 @@ void Miner::clear() {
440440
std::cout << "Clearing miner's data..." << std::endl;
441441
_inited = false;
442442
for (auto &sieve : _sieves) {
443-
delete sieve.factorsTable;
444-
delete sieve.factorsToEliminate;
443+
delete[] sieve.factorsTable;
444+
#ifndef LIGHT
445+
delete[] reinterpret_cast<__m256i*>(sieve.factorsToEliminate);
446+
#else
447+
delete[] sieve.factorsToEliminate;
448+
#endif
445449
for (uint64_t j(0) ; j < _parameters.sieveIterations ; j++)
446-
delete sieve.additionalFactorsToEliminate[j];
447-
delete sieve.additionalFactorsToEliminate;
448-
delete sieve.additionalFactorsToEliminateCounts;
450+
delete[] sieve.additionalFactorsToEliminate[j];
451+
delete[] sieve.additionalFactorsToEliminate;
452+
delete[] sieve.additionalFactorsToEliminateCounts;
449453
}
450454
_sieves.clear();
451455
_primes32.clear();
@@ -1177,11 +1181,11 @@ void Miner::_doTasks(const uint16_t id) { // Worker Threads run here until the m
11771181
}
11781182
// Thread clean up.
11791183
for (int i(0) ; i < _parameters.sieveWorkers ; i++) {
1180-
delete factorsCacheCounts[i];
1181-
delete factorsCache[i];
1184+
delete[] factorsCacheCounts[i];
1185+
delete[] factorsCache[i];
11821186
}
1183-
delete factorsCacheCounts;
1184-
delete factorsCache;
1187+
delete[] factorsCacheCounts;
1188+
delete[] factorsCache;
11851189
}
11861190

11871191
void Miner::_manageTasks() {
@@ -1329,6 +1333,7 @@ void Miner::_suggestLessMemoryIntensiveOptions(const uint64_t suggestedPrimeTabl
13291333
std::cout << "Try to use the following options in the " << confPath << " configuration file and retry:" << std::endl;
13301334
std::cout << "PrimeTableLimit = " << suggestedPrimeTableLimit << std::endl;
13311335
std::cout << "SieveWorkers = " << suggestedSieveWorkers << std::endl;
1336+
waitForUser();
13321337
}
13331338

13341339
bool Miner::hasAcceptedPatterns(const std::vector<std::vector<uint64_t>> &acceptedPatterns) const {

0 commit comments

Comments
 (0)