Skip to content

Commit

Permalink
Extend the range of the main lock.
Browse files Browse the repository at this point in the history
It was possible for the used data structures to be modified by the
block acceptor thread while used by the stake thread. This could
result in a crash, see gridcoin-community#865.
  • Loading branch information
denravonska committed Jan 23, 2018
1 parent 29ba608 commit cf3b109
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,6 @@ void StakeMiner(CWallet *pwallet)

while (!fShutdown)
{

//wait for next round
MilliSleep(nMinerSleep);

Expand Down Expand Up @@ -880,6 +879,10 @@ void StakeMiner(CWallet *pwallet)
continue;
}

// Lock main lock since GetNextProject and subsequent calls
// require the state to be static.
LOCK(cs_main);

GetNextProject(true);

// * Create a bare block
Expand Down Expand Up @@ -920,7 +923,6 @@ void StakeMiner(CWallet *pwallet)
}

// * delegate to ProcessBlock
LOCK(cs_main);
if (!ProcessBlock(NULL, &StakeBlock, true))
{
{ LOCK(MinerStatus.lock);
Expand Down

0 comments on commit cf3b109

Please sign in to comment.