You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
potential stack corruption when misusing "crank" #528
The problem is that some async operations such as retrieving data from a remote are not events in the queue, which may cause the "crank" call to return 0.
In that case, the boolean "done" may get out of scope but the callback is still pending (it's just a matter of somebody else calling "crank").
When the callback is finally called, the stack will be overwritten when the callback performs "done = true" in the example above.
The pattern should probably be changed to
bool done = false;
asio::error_code ec;
uint32_t lclNum = mApp.getLedgerManager().getLastClosedLedgerNum();
uint32_t ledgerNum = mApp.getLedgerManager().getLedgerNum();
hm.publishHistory([&done, &ec](asio::error_code const& ec2)
{
ec = ec2;
done = true;
});
while (!done)
{
mApp.getClock().crank(false));
// maybe a "sleep" of some sort to avoid spinning the thread
}
Activity