Skip to content
This repository was archived by the owner on Apr 24, 2022. It is now read-only.

Commit bf3dc75

Browse files
committedJan 1, 2018
Fix segfault and deadlock in CUDAMiner.
* Add stopWorking() to destructor before pause() to prevent workLoop from continuing on deleted members. * Scope minerWork lock to just the m_miners member, preventing deadlock with collectHashRate. * Fix race with hashrateTimer by canceling and removing after serviceThread is joined to prevent retriggering the timer in serviceThread. * Add boost::system to target_link_libraries for devcore for those that don't compile with stratum.
1 parent 2868fff commit bf3dc75

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed
 

‎libdevcore/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ file(GLOB SOURCES "*.cpp")
44
find_package(Threads)
55

66
add_library(devcore ${SOURCES} ${HEADERS})
7-
target_link_libraries(devcore PUBLIC Boost::boost)
7+
target_link_libraries(devcore PUBLIC Boost::boost Boost::system)
88
target_link_libraries(devcore PRIVATE Threads::Threads)

‎libethash-cuda/CUDAMiner.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ CUDAMiner::CUDAMiner(FarmFace& _farm, unsigned _index) :
9696

9797
CUDAMiner::~CUDAMiner()
9898
{
99+
stopWorking();
99100
pause();
100101
delete m_miner;
101102
delete m_hook;
@@ -189,7 +190,7 @@ void CUDAMiner::workLoop()
189190
if (current.exSizeBits >= 0)
190191
startN = current.startNonce | ((uint64_t)index << (64 - 4 - current.exSizeBits)); // this can support up to 16 devices
191192
m_miner->search(current.header.data(), upper64OfBoundary, *m_hook, (current.exSizeBits >= 0), startN);
192-
193+
193194
// Check if we should stop.
194195
if (shouldStop())
195196
{

‎libethcore/Farm.h

+9-7
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,19 @@ class Farm: public FarmFace
135135
*/
136136
void stop()
137137
{
138-
Guard l(x_minerWork);
139-
m_miners.clear();
140-
m_isMining = false;
141-
142-
if (p_hashrateTimer) {
143-
p_hashrateTimer->cancel();
138+
{
139+
Guard l(x_minerWork);
140+
m_miners.clear();
141+
m_isMining = false;
144142
}
145143

146144
m_io_service.stop();
147145
m_serviceThread.join();
148-
p_hashrateTimer = nullptr;
146+
147+
if (p_hashrateTimer) {
148+
p_hashrateTimer->cancel();
149+
p_hashrateTimer = nullptr;
150+
}
149151
}
150152

151153
void collectHashRate()

0 commit comments

Comments
 (0)
This repository has been archived.