mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 11:38:37 +00:00
test: interface_http: Fix for case when a response doesn't arrive in one recv #36729
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36729
Loading…
Reference in a new issue
No description provided.
Delete branch "2610-interface-http-test-fix"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The
interface_http.pytest can fail in the -- improbable -- case when network reads happen to arrive in smaller chunks (when reading HTTP response from the socket).Related to #36726 .
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. In test using sockets on the same host, this is not very likely, but still possible.
This tests reads complete HTTP responses, by checking for the HTTP response code texts (
"HTTP/1.1 200"). In doing so, it implicitly assumes that one HTTP response arrives in onerecv(). There is no guarantee for this.This was found -- and can be reproduced -- by using a reproducer patch, that forces all socket sends to use smaller chunking. For the run with the reproducer see #36724 .
The issue is test-code only, the non-test code is correct.
The fix is to follow standard HTTP parsing: read the header until the new line, extract the content length from the header, and read the body of that size. Use repeated receives if needed, until the full response is read.
This fix makes the test more robust, even though a failure due to this issue in CI is very unlikely, but not impossible.
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.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.No verified findings are available from this review.
Review coverage was incomplete.
Reviewed:
568d8f23edb2· Full review report · Previous reportspermalink
Minor changes, applied DrahtBot suggestions (
assert_greater_than_or_equal).Additional validation: The fix has been validated as well in a run with the reproducer, see https://github.com/bitcoin/bitcoin/pull/36724#issuecomment-6846132450
(current version
568d8f23ed)cc @pinheadmz
tACK
568d8f23eFixes the pipelining failure reproduced under forced chunking, which fails deterministically on master.
The drain-loop change is necessary; reverting it brings back the timeout. The missing Content-Length fallback is safe since bitcoind always sends it for HTTP/1.1 responses with a body (
httpserver.cpp:574–583).Verified with the reproducer and a normal build. No regressions.