WIP: [DONTMERGE] Test run with reproducer for forced chunked recv #36751

Closed
optout21 wants to merge 2 commits from 2610-net-recv-chunks-reproducer into master AGit
optout21 commented 2026-11-04 07:48:54 +00:00 (Migrated from github.com)

WARNING: NOT INTENDED FOR MERGING!

Performing a test run with forced chunked recv.

All networking code using sockets must not make assumption about the chunking of the incoming/outgoing data, and should be resilient against any chunking. Normally, the chunking of the sends of the writer dictate the chunking of the receives at the reader, but this is not guaranteed by IP/TCP, intermediate networking elements may change the packet structure.

This branch contains a stress test reproducer. For every socket read, recv() is not called to read all available data, but data is read and returned in smaller chunks. The goal is to test code for robustness in face of unexpected chunking of the data.

This PR will be closed once the test runs complete, and kept for reference (some tests are expected to fail).

Similar to #36724 .

WARNING: NOT INTENDED FOR MERGING!

WARNING: NOT INTENDED FOR MERGING! Performing a test run with forced chunked recv. All networking code using sockets must not make assumption about the chunking of the incoming/outgoing data, and should be resilient against any chunking. Normally, the chunking of the sends of the writer dictate the chunking of the receives at the reader, but this is not guaranteed by IP/TCP, intermediate networking elements may change the packet structure. This branch contains a stress test reproducer. For every socket read, `recv()` is not called to read all available data, but data is read and returned in smaller chunks. The goal is to test code for robustness in face of unexpected chunking of the data. This PR will be closed once the test runs complete, and kept for reference (some tests are expected to fail). Similar to #36724 . WARNING: NOT INTENDED FOR MERGING!
DrahtBot commented 2026-11-04 07:49:03 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36751 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36751.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36751#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. A summary of reviews will appear here. <!--5faf32d7da4f0f540f40219e4f7537a3-->
DrahtBot commented 2026-11-04 07:55:51 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task macOS native: https://github.com/bitcoin/bitcoin/actions/runs/41794882715/job/126456522377
LLM reason (✨ experimental): CI failed because the sock_tests CTest test failed.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `macOS native`: https://github.com/bitcoin/bitcoin/actions/runs/41794882715/job/126456522377</sub> <sub>LLM reason (✨ experimental): CI failed because the `sock_tests` CTest test failed.</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
First-time contributor

🟠 Minor · Forced chunking discards datagram replies and can block shutdown

The reproducer caps UDP and netlink receives as though they were streams, discarding port-mapping replies and potentially preventing shutdown with port mapping enabled on Linux.

Location: src/util/sock.cpp:82 (head).

🔵 Suggestion · The receive-loop fix remains tied to the unmerged reproducer

The test's receive loop handles legal TCP short reads independently of the diagnostic shim, so it is worth preserving in a separate PR.

Location: src/test/sock_tests.cpp:132 (head).

🔵 Suggestion · Mock-socket unit tests bypass the forced receive chunking

Mock-backed I2P and HTTP unit tests bypass the new limiter, so their results do not measure this run's additional forced chunking.

Location: src/util/sock.cpp:58 (head).

Review coverage was incomplete.


Reviewed: 9c516241658b · Full review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:4d44b6ffa09c54db24f8f0ab27ae388beae06a733efcae741ca64db76bb1c938:7efd3c3ba41667382004cfa7a7db56605da7d8f9b7ab69bc483f27117390ba48 --> <!-- ralph-base:0e38ad26af922abdc0fc36c9379e17efd2a72b80 --> <!-- ralph-head:9c516241658b661a4ffb845971ed19e069a47a9d --> <!-- ralph-case:bd036e2537b1153989d5243fe10efd73e2084cbd109d72fe7b3885387492c654 --> **🟠 Minor · Forced chunking discards datagram replies and can block shutdown** The reproducer caps UDP and netlink receives as though they were streams, discarding port-mapping replies and potentially preventing shutdown with port mapping enabled on Linux. Location: [`src/util/sock.cpp:82`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/9c516241658b661a4ffb845971ed19e069a47a9d/src/util/sock.cpp#L82>) (head). **🔵 Suggestion · The receive-loop fix remains tied to the unmerged reproducer** The test's receive loop handles legal TCP short reads independently of the diagnostic shim, so it is worth preserving in a separate PR. Location: [`src/test/sock_tests.cpp:132`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/9c516241658b661a4ffb845971ed19e069a47a9d/src/test/sock_tests.cpp#L132>) (head). **🔵 Suggestion · Mock-socket unit tests bypass the forced receive chunking** Mock-backed I2P and HTTP unit tests bypass the new limiter, so their results do not measure this run's additional forced chunking. Location: [`src/util/sock.cpp:58`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/9c516241658b661a4ffb845971ed19e069a47a9d/src/util/sock.cpp#L58>) (head). Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`9c516241658b`](<https://git.fish.foo/bitcoin/bitcoin/commit/9c516241658b661a4ffb845971ed19e069a47a9d>) · [Full review report](<https://review.fish.foo/traces/36751-9c516241658b661a4ffb845971ed19e069a47a9d-2187-6.html>) · [Previous reports](<https://review.fish.foo/traces/36751/>) [permalink](<https://review.fish.foo/traces/36751-9c516241658b661a4ffb845971ed19e069a47a9d-2187-6.html>)
optout21 commented 2026-11-04 08:46:02 +00:00 (Migrated from github.com)

A socket unit test failed (sock_tests/send_and_receive), so integration tests were not executed.
Including a commit with a fix for the unit test, for a 2nd run.

test/sock_tests.cpp(132): error: in "sock_tests/send_and_receive": check receiver.Recv(recv_buf, sizeof(recv_buf), 0) == msg_len has failed [1 != 4]
test/sock_tests.cpp(133): error: in "sock_tests/send_and_receive": check strncmp(msg, recv_buf, msg_len) == 0 has failed [1 != 0]
test/sock_tests.cpp(132): error: in "sock_tests/send_and_receive": check receiver.Recv(recv_buf, sizeof(recv_buf), 0) == msg_len has failed [1 != 4]
test/sock_tests.cpp(133): error: in "sock_tests/send_and_receive": check strncmp(msg, recv_buf, msg_len) == 0 has failed [-1 != 0]
A socket unit test failed (`sock_tests/send_and_receive`), so integration tests were not executed. Including a commit with a fix for the unit test, for a 2nd run. ``` test/sock_tests.cpp(132): error: in "sock_tests/send_and_receive": check receiver.Recv(recv_buf, sizeof(recv_buf), 0) == msg_len has failed [1 != 4] test/sock_tests.cpp(133): error: in "sock_tests/send_and_receive": check strncmp(msg, recv_buf, msg_len) == 0 has failed [1 != 0] test/sock_tests.cpp(132): error: in "sock_tests/send_and_receive": check receiver.Recv(recv_buf, sizeof(recv_buf), 0) == msg_len has failed [1 != 4] test/sock_tests.cpp(133): error: in "sock_tests/send_and_receive": check strncmp(msg, recv_buf, msg_len) == 0 has failed [-1 != 0] ```
optout21 commented 2026-11-04 12:55:51 +00:00 (Migrated from github.com)

CI runs timed out, in some cases a log line is created for every read, and the many small chunks slowed down runs considerably. In local runs this didn't cause a problem.
I've changed the reproducer to break up less aggressively: for large streams always read the third of the available data at once. I hope this will make a difference.

CI runs timed out, in some cases a log line is created for every read, and the many small chunks slowed down runs considerably. In local runs this didn't cause a problem. I've changed the reproducer to break up less aggressively: for large streams always read the _third_ of the available data at once. I hope this will make a difference.
optout21 commented 2026-11-05 11:25:13 +00:00 (Migrated from github.com)

CI runs have completed, with some failures (as expected).

Added failed cases to #36726 -- sock_tests/send_and_receive unit test, interface_http.py,feature_torcontrol.py.

Closing this PR (it was not intended for merging, keeping it for reference).

CI runs have completed, with some failures (as expected). Added failed cases to #36726 -- `sock_tests/send_and_receive` unit test, `interface_http.py`,`feature_torcontrol.py`. Closing this PR (it was not intended for merging, keeping it for reference).
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36751
No description provided.