Compare commits

...

2 Commits

Author SHA1 Message Date
Duke
9519e3a6cd Merge branch 'bip155' of https://git.hush.is/hush/hush3 into bip155 2023-01-18 23:24:38 -05:00
Duke
d5e9ef763d Prevent coredump when -proxy=... -externalip=... is used
Replace an assert() in Unserialize() with the actual behavior we want,
i.e. making sure that vRandom is empty. Before the assert() was added,
the code called Clear() which ensured vRandom was empty. Clear() was
changed to the assert() in BTC commit b138973a8b4bbe061ad97011f278a21e08ea79e6
to prevent recursive locks but risks crashing the node. Instead, we
just empty out vRandom.

The addition of EXCLUSIVE_LOCKS_REQUIRED is not needed to fix
this but seems prudent since Serialize() has it and the original code
from BTC has EXCLUSIVE_LOCKS_REQUIRED on all the methods of this class.

As a side note, crashing a full node with an assert() and possibly
corrupting the wallet.dat, block files and other data is REALLY
FUCKING DUMB. Instead, code should be written to prevent the
possibility of crashing or throw an exception with a useful error.
2023-01-18 23:02:41 -05:00
2 changed files with 3 additions and 3 deletions

View File

@ -435,11 +435,11 @@ public:
}
template<typename Stream>
void Unserialize(Stream& s_)
void Unserialize(Stream& s_) EXCLUSIVE_LOCKS_REQUIRED(!cs)
{
LOCK(cs);
assert(vRandom.empty());
std::vector<int>().swap(vRandom);
Format format;
s_ >> Using<CustomUintFormatter<1>>(format);

View File

@ -2277,8 +2277,8 @@ void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler)
}
uiInterface.InitMessage(_("Loading addresses..."));
// Load addresses for peers.dat
int64_t nStart = GetTimeMillis();
fprintf(stderr, "%s: Loading addresses for peers.dat at %ld\n", __func__, nStart);
{
CAddrDB adb;
if (!adb.Read(addrman))