-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Fix segmentation fault during syncing #5834
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5834 +/- ##
==========================================
- Coverage 64.1% 64.09% -0.01%
==========================================
Files 362 362
Lines 30903 30902 -1
Branches 3429 3429
==========================================
- Hits 19811 19808 -3
+ Misses 9865 9863 -2
- Partials 1227 1231 +4 |
Do I understand correctly that the reason for crash is that new Then could we remove default constructor of |
Ran a sync overnight on Linux for ~9 hours and didn't hit the AV |
@gumb0: Yes, that's correct - attempting to retrieve an element from the unordered map which doesn't exist (via the [] operator) results in it being default constructed and inserted, then returned. When we try to deref m_host we get the av. Good idea about removing the default ctor, I'll do that. |
5e789d7
to
df96f20
Compare
Rebased and updated changelog |
Segfault is occurring when a peer reconnects while its disconnect is still pending, which results in a live Session but no entry in EthereumCapability::m_peers. EthereumCapability::interpretCapabilityPacket directly accesses m_peers via node ID rather than using a lookup function, which is causing the segfault.
df96f20
to
d298fa2
Compare
Fix #5832, #5633
I suspect the segmentation fault is occurring when a peer reconnects while its disconnect is
still pending (see here for a detailed description), which results in a live
Session
but no entry inEthereumCapability::m_peers
.EthereumCapability::interpretCapabilityPacket
directly accessesm_peers
via the[]
operator rather than using a lookup function, which can cause a segfault if the entry with the node ID has already been removed.This fix will trigger an exception to be thrown when the peer being looked up is not present in
EthereumCapability::m_peers
. This isn't ideal, but is good enough for now until we can design a proper fix for the "reconnect during pending disconnect" issue (#5835)