Skip to content

Commit

Permalink
Re-lock after activating dependencies (bug found by @cryptocode)
Browse files Browse the repository at this point in the history
Otherwise, could call state_change to `expired_unconfirmed` without owning the mutex
  • Loading branch information
guilhermelawless authored Mar 4, 2020
1 parent de8d66e commit 9787531
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion nano/node/election.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ bool nano::election::transition_time (nano::confirmation_solicitor & solicitor_a
state_change (nano::election::state_t::active, nano::election::state_t::backtracking);
lock.unlock ();
activate_dependencies ();
lock.lock ();
}
break;
case nano::election::state_t::backtracking:
Expand All @@ -298,7 +299,6 @@ bool nano::election::transition_time (nano::confirmation_solicitor & solicitor_a
debug_assert (false);
break;
}
// Note: lock (timepoints_mutex) is at an unknown state here - possibly unlocked before activate_dependencies
if (!confirmed () && std::chrono::minutes (5) < std::chrono::steady_clock::now () - election_start)
{
result = true;
Expand Down

0 comments on commit 9787531

Please sign in to comment.