fuzz: p2p: Detect peer deadlocks

This commit is contained in:
MarcoFalke 2023-12-06 12:03:56 +01:00
parent 6d5790956f
commit fae1e7e012
No known key found for this signature in database
2 changed files with 13 additions and 6 deletions

View file

@ -78,13 +78,17 @@ FUZZ_TARGET(process_messages, .init = initialize_process_messages)
connman.FlushSendBuffer(random_node); connman.FlushSendBuffer(random_node);
(void)connman.ReceiveMsgFrom(random_node, std::move(net_msg)); (void)connman.ReceiveMsgFrom(random_node, std::move(net_msg));
random_node.fPauseSend = false;
try { bool more_work{true};
connman.ProcessMessagesOnce(random_node); while (more_work) { // Ensure that every message is eventually processed in some way or another
} catch (const std::ios_base::failure&) { random_node.fPauseSend = false;
try {
more_work = connman.ProcessMessagesOnce(random_node);
} catch (const std::ios_base::failure&) {
}
g_setup->m_node.peerman->SendMessages(&random_node);
} }
g_setup->m_node.peerman->SendMessages(&random_node);
} }
SyncWithValidationInterfaceQueue(); SyncWithValidationInterfaceQueue();
g_setup->m_node.connman->StopNodes(); g_setup->m_node.connman->StopNodes();

View file

@ -70,7 +70,10 @@ struct ConnmanTestMsg : public CConnman {
bool relay_txs) bool relay_txs)
EXCLUSIVE_LOCKS_REQUIRED(NetEventsInterface::g_msgproc_mutex); EXCLUSIVE_LOCKS_REQUIRED(NetEventsInterface::g_msgproc_mutex);
void ProcessMessagesOnce(CNode& node) EXCLUSIVE_LOCKS_REQUIRED(NetEventsInterface::g_msgproc_mutex) { m_msgproc->ProcessMessages(&node, flagInterruptMsgProc); } bool ProcessMessagesOnce(CNode& node) EXCLUSIVE_LOCKS_REQUIRED(NetEventsInterface::g_msgproc_mutex)
{
return m_msgproc->ProcessMessages(&node, flagInterruptMsgProc);
}
void NodeReceiveMsgBytes(CNode& node, Span<const uint8_t> msg_bytes, bool& complete) const; void NodeReceiveMsgBytes(CNode& node, Span<const uint8_t> msg_bytes, bool& complete) const;