bitcoin: Assertion failed: (data.size() > node.nSendOffset), function SocketSendData, file net.cpp, line 837

Is there an existing issue for this?

  • I have searched the existing issues

Current behaviour

crashed

Expected behaviour

not crash

Steps to reproduce

compiled master at d1ae96755a0f9d7e12c3f6741c030d8ea6d0416f, did mainnet IBD, around 40 hours after IBD crashed with the asseration fail.

Relevant log output

unclear if relevant but these are the final lines

2023-06-24T06:15:52Z Saw new header hash=00000000000000000000f72e1a37859593a848a2f9b88eb9e5c3f0d8c971d89a height=795677
2023-06-24T06:15:52Z [net] Saw new cmpctblock header hash=00000000000000000000f72e1a37859593a848a2f9b88eb9e5c3f0d8c971d89a peer=1
2023-06-24T06:15:52Z UpdateTip: new best=00000000000000000000f72e1a37859593a848a2f9b88eb9e5c3f0d8c971d89a height=795677 version=0x20800000 log2_work=94.260280 tx=855881332 date='2023-06-24T06:15:33Z' progress=1.000000 cache=6.1MiB(47317txo)
2023-06-24T06:20:25Z New outbound peer connected: version: 70016, blocks=795677, peer=557 (outbound-full-relay)
2023-06-24T06:20:26Z New outbound peer connected: version: 70016, blocks=795677, peer=558 (outbound-full-relay)
Assertion failed: (data.size() > node.nSendOffset), function SocketSendData, file net.cpp, line 837.

How did you obtain Bitcoin Core

Compiled from source

What version of Bitcoin Core are you using?

master@d1ae96755a0f9d7e12c3f6741c030d8ea6d0416f

Operating system and version

macOS 13.4 (22F66)

Machine specifications

M2 Max

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 21 (19 by maintainers)

Most upvoted comments

So that seems to confirm my guess that this is a macOS bug? (The total data is 24 bytes, but macOS send() returned 28)

My suggestion would be to call Tim Cook or switch to Linux.

I’ve been running the two instances for several months in more or less the same conditions without any problems, and running them on that specific v25.1 commit for at least a few weeks.

It’s possible there was more network activity happening on the machine than usual, but I couldn’t say for sure.

@FelixWeis were you able to perform a bisect here?

Can you try with my suggested diff?

diff --git a/src/net.cpp b/src/net.cpp
index a96ffcfbe9..6c9f928f0d 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -854,6 +854,10 @@ size_t CConnman::SocketSendData(CNode& node) const
             node.nSendBytes += nBytes;
             node.nSendOffset += nBytes;
             nSentSize += nBytes;
+            if (node.nSendOffset > data.size()) {
+            LogPrint(BCLog::NET, "socket sent %s bytes (total: %s, offset: %s) for peer=%d.\n", nBytes, data.size(), node.nSendOffset, node.GetId());
+            assert(false);
+            }
             if (node.nSendOffset == data.size()) {
                 node.nSendOffset = 0;
                 node.nSendSize -= data.size();